Page MenuHomePhabricator

JSON output from #ask does not escape "
Closed, ResolvedPublic


Author: halfcountplus

Here's an example:

        "label": "Follow",

        "shortdesc": "Implements "tail -f" functionality",

        "uri" : "http://localhost/wiki/index.php?title=Follow",

Version: unspecified
Severity: normal



Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:04 PM
bzimport set Reference to bz23946.

matt.voysey wrote:

The problem is not limited to property values. Valid MediaWiki article names containing quotes (such as "Weird Al" Yankovic) also create invalid JSON output:


"label" : ""Weird Al" Yankovic",
"uri" : "http://localhost/mediawiki/index.php?title=""Weird Al" Yankovic",


I fixed this particular case by hacking SMW_QP_JSONlink.php to do a str_replace:

valuestack[] = '"uri" : "' . $wgServer . $wgScriptPath . '/index.php?title=' . str_replace("\"", "\\\"", $prefixedtext) . '"';

As a secondary issue: Notice also that the "label" is getting htmlescaped, which is probably not what is actually wanted in JSON output? Changing this now though would break existing users, so I guess we're stuck with that one?

Unknown Object (User) added a comment.Jul 5 2012, 7:51 PM

The string escape problem is solved with the new JSON export but please be aware that the JSON structure has changed beginning with (bug 37418).