php/php-src — pull request #436 by TazeTSchnitzel (2013-09-10 21:46:44+00:00)
Title: Fixed bug #64874 (json_decode handles whitespace and case-sensitivity incorrectly)

This is for PHP-5.4 but it should also be applied to 5.5 and master.

https://bugs.php.net/bug.php?id=64874

There is a small possible backwards-compatibility issue here: Previously, `json_decode('tRUe')`, and other capitalisation variants of `true`, `false` or `null` were accepted. However, the RFC states only the lowercase variants should be supported, and this pull request fixes that (as well as fixing the whitespace issue). Hence, once this bug is fixed, code that relied on incorrect capitalisations of these constants would break. That being said, I seriously doubt there is any that relies on it at all. `json_encode` does not output bad JSON like that, and this issue will only occur when you have a top-level constant, i.e. `"[tRue]"` didn't work anyway, the only thing you could get away with was `"tRue"`. I also do not know of any parser that outputs this. Furthermore, the page on wiki.php.net states, albeit incorrectly, that it implements JSON (strictly speaking, it's a slight superset allowing top-level constants, strings and numbers). Anyone who read the spec would not expect to rely on such incorrect capitalised constants.