#49366 [Opn]: json_encode incorrectly escapes slashes (/)
| From: | jani@php.net | Date: | Wed, 26 Aug 2009 08:50:12 +0000 |
| Subject: | #49366 [Opn]: json_encode incorrectly escapes slashes (/) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-141527@lists.php.net to get a copy of this message | ||
ID: 49366
Updated by: jani@php.net
Reported By: don at smugmug dot com
Status: Open
-Bug Type: JSON related
+Bug Type: Feature/Change Request
Operating System: CentOS 5.3
PHP Version: 5.3.0
New Comment:
It's not incorrect to escape slashes. It's also suggested on the RFC to
do so. Just look at the chart on http://www.json.org/ for
string..
But since it isn't wrong either NOT to escape them, I'll just
reclassify this. We can add another option to that optional bitmask
"options".
Previous Comments:
------------------------------------------------------------------------
[2009-08-25 23:32:14] don at smugmug dot com
Description:
------------
When given a string with slashes in it, despite the JSON docs
suggesting
that's legal, json_encode escapes them anyway.
http://www.json.org/ says
"any-Unicode-character-except-"-or-\-or
control-character"
JSONLint at http://www.jsonlint.com/ also validates slashes
that aren't
escaped as valid.
This adds response weight, and makes further processing much more
complex.
Reproduce code:
---------------
$vars['url'] = "http://www.example.com/";
echo json_encode($vars);
Expected result:
----------------
{"url":"http://www.example.com/"}
Actual result:
--------------
{"url":"http:\/\/www.example.com\/"}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49366&edit=1