Tabs must also be escaped in JSON strings

If database table data contains tab characters (0x09) then those
must also be escaped along with newlines and carriage returns for
the resulting JSON file to be valid.
This commit is contained in:
Janne Cederberg 2016-07-07 15:34:59 +03:00 committed by Jakub Vrana
parent 4c78976cba
commit dedbd01f64

View file

@ -243,7 +243,7 @@ function json_row($key, $val = null) {
echo "{";
}
if ($key != "") {
echo ($first ? "" : ",") . "\n\t\"" . addcslashes($key, "\r\n\"\\/") . '": ' . ($val !== null ? '"' . addcslashes($val, "\r\n\"\\/") . '"' : 'null');
echo ($first ? "" : ",") . "\n\t\"" . addcslashes($key, "\r\n\t\"\\/") . '": ' . ($val !== null ? '"' . addcslashes($val, "\r\n\"\\/") . '"' : 'null');
$first = false;
} else {
echo "\n}\n";