php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57209 Tabs in Javascript strings break json_decode()
Submitted: 2006-08-30 16:31 UTC Modified: 2006-08-31 11:25 UTC
From: rasmus@php.net Assigned:
Status: Not a bug Package: json (PECL)
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: rasmus@php.net
New email:
PHP Version: OS:

 

 [2006-08-30 16:31 UTC] rasmus@php.net
Description:
------------
print_r(json_decode('{ "abc": 12, "foo": "bar   bar" }'));

With a TAB between bar bar there doesn't work.  It works in the 1.1.x version before the rewrite, but breaks now in 1.2.1.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-31 00:23 UTC] omar@php.net
I don't think this is valid JSON as per the JSON spec.

(Using JSON_checker from: http://www.json.org/JSON_checker/)

[omar@xxx jc]$ cat tab.json 
{ "abc": 12, "foo": "bar        bar" }
[omar@xxx jc]$ ./JSON_checker tab.json 
tab.json syntax error at character 24

Since json_decode is based on JSON_checker, it'll just return NULL here due to the "invalid" JSON input.

I'm not sure whether this is right or wrong -- I'd have to ask Douglas.

Shouldn't the tab be a \t if encoded using json_encode?
 [2006-08-31 11:25 UTC] rasmus@php.net
Ok, the word from Douglas is that it is indeed illegal to have raw tabs there.  No bug here.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 08:01:29 2024 UTC