You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
serializers/ARC2_RDFJSONSerializer.php->jsonEscape($v) begins by escaping the passed var using json_encode(). If the var is a string, the result will be a string wrapped by quotes. The function then removes these quotes using trim(),
if (function_exists('json_encode')) return trim(json_encode($v), '"');
However, if a string passed into the function ends with a quote, json_encode() will result in,
"This is a string "ending in a quote/""
trim() will then remove both quotes, resulting in,
This is a string "ending in a quote/
When this string is passed to the JSON output, the result is,
{
"example": "This is a string "ending in a quote/"
}
... where the errant slash at the end escapes the JSON ending quote, resulting in invalid JSON.
This is the update I've made locally, which explicitly removes a single quote from the beginning and end if they exist.
if (function_exists('json_encode')) { // Updated by Craig
$v = json_encode($v);
if ('"'==substr($v,0,1)&&'"'==substr($v,-1,1)) $v = substr($v, 1, -1);
return $v;
}
(Should probably use regex instead.)
Thanks!
The text was updated successfully, but these errors were encountered:
serializers/ARC2_RDFJSONSerializer.php->jsonEscape($v) begins by escaping the passed var using json_encode(). If the var is a string, the result will be a string wrapped by quotes. The function then removes these quotes using trim(),
if (function_exists('json_encode')) return trim(json_encode($v), '"');
However, if a string passed into the function ends with a quote, json_encode() will result in,
"This is a string "ending in a quote/""
trim() will then remove both quotes, resulting in,
This is a string "ending in a quote/
When this string is passed to the JSON output, the result is,
{
"example": "This is a string "ending in a quote/"
}
... where the errant slash at the end escapes the JSON ending quote, resulting in invalid JSON.
This is the update I've made locally, which explicitly removes a single quote from the beginning and end if they exist.
if (function_exists('json_encode')) { // Updated by Craig
$v = json_encode($v);
if ('"'==substr($v,0,1)&&'"'==substr($v,-1,1)) $v = substr($v, 1, -1);
return $v;
}
(Should probably use regex instead.)
Thanks!
The text was updated successfully, but these errors were encountered: