From: chrivers at iversen-net dot dk Operating system: All PHP version: 5.4.15 Package: JSON related Bug Type: Bug Bug description:json_decode handles whitespace and case-sensitivity incorrectly
Description: ------------ There are 2 problems with the json_decode function. 1) It only sometimes disregards whitespace The RFC clearly says: """Insignificant whitespace is allowed before or after any of the six structural characters.""" 2) It only sometimes enforces lowercase-ness of identifiers The RFC clearly says: """The literal names MUST be lowercase. No other literal names are allowed.""" The test script demonstrates this Test script: --------------- <? function json_cmp($x, $y) { print var_dump(json_decode($x) === $y); } // works json_cmp("true", true); // fails - is actually true json_cmp("tRue", NULL); // fails - is actually NULL json_cmp("true ", true); // works json_cmp("[true ] ", array(true)); // works, even though the non-array version fails json_cmp("[tRue]", NULL); ?> Expected result: ---------------- true * 5 Actual result: -------------- bool(true) bool(false) bool(false) bool(true) bool(true) -- Edit bug report at https://bugs.php.net/bug.php?id=64874&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64874&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64874&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64874&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=64874&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=64874&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=64874&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=64874&r=needscript Try newer version: https://bugs.php.net/fix.php?id=64874&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=64874&r=support Expected behavior: https://bugs.php.net/fix.php?id=64874&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=64874&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=64874&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=64874&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64874&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=64874&r=dst IIS Stability: https://bugs.php.net/fix.php?id=64874&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=64874&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=64874&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=64874&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=64874&r=mysqlcfg