[PATCH] Fix octal parsing (finally)
| From: | Andrea Faulds | Date: | Sat, 10 Jan 2015 22:37:26 +0000 |
| Subject: | [PATCH] Fix octal parsing (finally) | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-80334@lists.php.net to get a copy of this message | ||
Hey internals,
A longstanding PHP bug is that invalid octal digits simply terminate the literal and are ignored,
rather than generating a compile error. Thus, this is valid:
$x = 0109; // same as 010, or 8
I see no particular reason why this behaviour should be preserved. I’ve written a patch that would
finally fix it, and avoid similar parsing issues in future (e.g. the resurgence of the hex addition
bug), by erroring when strtol doesn’t reach the end of the literal.
The pull request is here: https://github.com/php/php-src/pull/987
I think this would be an acceptable BC break for PHP 7.
Thoughts?
--
Andrea Faulds
http://ajf.me/