Bug #77623 [Opn->Nab]: jsno_encode handle badly backslashes
| From: | cmb@php.net | Date: | Fri, 15 Feb 2019 12:45:46 +0000 |
| Subject: | Bug #77623 [Opn->Nab]: jsno_encode handle badly backslashes | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-219593@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77623&edit=1
ID: 77623
Updated by: cmb@php.net
Reported by: marco dot biondi at docomodigital dot com
Summary: jsno_encode handle badly backslashes
-Status: Open
+Status: Not a bug
Type: Bug
Package: Unknown/Other Function
Operating System: any
PHP Version: Irrelevant
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
A single backslash in a JSON string literal would be an error.
Previous Comments:
------------------------------------------------------------------------
[2019-02-15 10:07:25] marco dot biondi at docomodigital dot com
Description:
------------
---
From manual page: https://php.net/function.json-encode
---
Just look at the sample code
Test script:
---------------
<?php
$a = "Srting with a slash: \ Just a slash is that I want!";
$b = "Srting with a slash: \\ Just a slash is that I want!";
var_dump($a);
var_dump(json_encode($a));
var_dump($b);
var_dump(json_encode($b));
Expected result:
----------------
string(51) "Srting with a slash: \ Just a slash is that I want!"
string(53) ""Srting with a slash: \ Just a slash is that I want!""
string(51) "Srting with a slash: \ Just a slash is that I want!"
string(53) ""Srting with a slash: \ Just a slash is that I want!""
Actual result:
--------------
string(51) "Srting with a slash: \ Just a slash is that I want!"
string(54) ""Srting with a slash: \\ Just a slash is that I want!""
string(51) "Srting with a slash: \ Just a slash is that I want!"
string(54) ""Srting with a slash: \\ Just a slash is that I want!""
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77623&edit=1