Bug #52172 [Bgs]: Impossible to escape escape character
| From: | harald dot lapp at gmail dot com | Date: | Thu, 24 Jun 2010 15:00:11 +0000 |
| Subject: | Bug #52172 [Bgs]: Impossible to escape escape character | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-151841@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52172&edit=1
ID: 52172
User updated by: harald dot lapp at gmail dot com
Reported by: harald dot lapp at gmail dot com
Summary: Impossible to escape escape character
Status: Bogus
Type: Bug
Package: JSON related
Operating System: *
PHP Version: 5.3.2
New Comment:
you are right, of course -- i got confused. sorry for reporting and
thanks for fast reply!
Previous Comments:
------------------------------------------------------------------------
[2010-06-24 16:51:27] rasmus@php.net
You are confusing PHP escapes and json escapes.
Watch:
php > $str = '["\\"]';
php > echo $str;
["\"]
That's obviously not valid json. What you actually want:
php > $str = '["\\\\"]';
php > echo $str;
["\\"]
php > var_dump(json_decode($str));
array(1) {
[0]=>
string(1) "\"
}
Works fine. No bug here.
------------------------------------------------------------------------
[2010-06-24 16:35:06] harald dot lapp at gmail dot com
Description:
------------
Apparently it's impossible to decode strings with escaped "escape"
character:
\\
this should work however, as it's written in the json specs on
http://json.org/
Test script:
---------------
<?php
var_dump(json_decode('["\\"]', true));
?>
Expected result:
----------------
array(1) {
[0]=>
string(1) "\"
}
Actual result:
--------------
NULL
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52172&edit=1