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/
Hi!
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.
I think it's a good idea. It is a BC break but I think it's a kind of
things that we can and should fix in PHP 7. Not sure if it needs an RFC
- technically it's still a break. I personally would just let it go as
is but if anybody objects I think then we should have RFC and a vote.
--
Stas Malyshev
smalyshev@gmail.com
Hi all,
Nice fix, Andrea!
On Sun, Jan 11, 2015 at 8:55 AM, Stanislav Malyshev smalyshev@gmail.com
wrote:
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.I think it's a good idea. It is a BC break but I think it's a kind of
things that we can and should fix in PHP 7. Not sure if it needs an RFC
- technically it's still a break. I personally would just let it go as
is but if anybody objects I think then we should have RFC and a vote.
Invalid literal should not be allowed. It's bug in script anyway and just a
simple bug fix
in engine. It should be ok for new major release w/o RFC as long as it's
mentioned in
UPGRADING clearly, IMHO.
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net
Hey:
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.
Agree, IMO previously behavior actually is a bug...
thanks
Thoughts?
Andrea Faulds
http://ajf.me/--
--
Xinchen Hui
@Laruence
http://www.laruence.com/
Hi!
Since it’s been a week and there have been no objections, I’ve merged the octal fix patch into php master:
https://github.com/php/php-src/commit/5f29b980514867f1a09969ca6a1c1f5fb00c3027
Finally, it is fixed after all these years :)
Andrea Faulds
http://ajf.me/