php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67502 json_decode accepts wrong strings without syntax error and still decodes
Submitted: 2014-06-23 13:29 UTC Modified: 2014-06-25 18:21 UTC
From: nevil85 at gmail dot com Assigned:
Status: Not a bug Package: JSON related
PHP Version: 5.5.13 OS:
Private report: No CVE-ID: None
 [2014-06-23 13:29 UTC] nevil85 at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.json-decode
---

json_decode accepts wrong strings without syntax error and still decodes

<?php
echo json_decode("2014-06-06");
echo json_last_error();
?>

The above code snippet returns 20140. It is a bug, as the error code is 0.

Test script:
---------------
<?php
echo json_decode("2014-06-06");
echo json_last_error();
?>



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-06-23 17:30 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2014-06-23 17:30 UTC] requinix@php.net
Works for me.

http://3v4l.org/HuGvq
 [2014-06-23 22:04 UTC] aharvey@php.net
How did you get PHP in the first place — did you compile it from source, or are you using packages? If the latter, which distribution are you on?

I'm wondering if this is an issue with one of the distros that are replacing ext/json for licensing reasons.
 [2014-06-25 14:53 UTC] nevil85 at gmail dot com
-Status: Feedback +Status: Open
 [2014-06-25 14:53 UTC] nevil85 at gmail dot com
You are correct. The bug is available only in a PHP distro, that came with Ubuntu 14 LTS OS.

Version:
PHP Version 5.5.9-1ubuntu4

System:
Linux <user> 3.13.0-29-generic #53-Ubuntu SMP <time> x86_64 

Build Date:
Apr 9 2014 17:08:00 

Thanks guys. I really appreciate.
 [2014-06-25 17:11 UTC] aharvey@php.net
-Status: Open +Status: Not a bug
 [2014-06-25 17:11 UTC] aharvey@php.net
Closing not a bug; you'll need to report this to the relevant Ubuntu developers at https://bugs.launchpad.net/ubuntu/+source/php-json.
 [2014-06-25 18:21 UTC] tyrael@php.net
I will poke Remi about it.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 06 08:01:27 2024 UTC