php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54010 json_decode can not handle data like {"A":0000}, but {"A":0} is fine
Submitted: 2011-02-14 05:47 UTC Modified: 2011-02-14 08:02 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: pan_yong_feng at hotmail dot com Assigned:
Status: Not a bug Package: Apache2 related
PHP Version: 5.3.5 OS: Ubuntu
Private report: No CVE-ID: None
 [2011-02-14 05:47 UTC] pan_yong_feng at hotmail dot com
Description:
------------
I have json data to decode using php api: json_decode(), 
But I found if there is a number of 0000 instead of 0. Such 
API will case thread of apache2 take 100% of cpu resource for about 
1 mins. 

I know 0000 is the legal number, but I think there should be a way to 
indicate that apache cannot handle, instead of just running exhausted.

Hoping this is useful for other developer. 
Thanks a lot.

Expected result:
----------------
Send some warning information.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-14 05:50 UTC] pan_yong_feng at hotmail dot com
e.g.
{"S":0000,"Y":5,"G":82.36431503,"T":33.99824477,"A":4,"Ai":0},
 [2011-02-14 08:02 UTC] scottmac@php.net
-Status: Open +Status: Bogus
 [2011-02-14 08:02 UTC] scottmac@php.net
I can't reproduce the cpu usage from cli on 5.3.5.

Looking at the json spec the number isn't valid.

I passed it through a linter too and you get.


syntax error, unexpected TNUMBER, expecting '}'
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 12:01:31 2024 UTC