-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Add parsing of hexadecimal strings for PHP 7 #14107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
PHP 7 does not handle the hexadecimal notation in is_numeric checks anymore, so the detection needs to be implemented explicitly.
@@ -200,6 +200,8 @@ public static function phpize($value) | |||
return false; | |||
case is_numeric($value): | |||
return '0x' === $value[0].$value[1] ? hexdec($value) : (float) $value; | |||
case preg_match('/^0x[0-9a-f]++$/i', $value): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity: what is the meaning of the double ++ ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a possessive quantifier to forbid backtracking (because backtracking cannot allow to find another way to match for this regex anyway). this allows to match much longer strings since we won't reach the backtracking limit.
See http://php.net/manual/en/regexp.reference.repetition.php for the doc about it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's clever. Thanks.
Thank you @stof. |
This PR was merged into the 2.3 branch. Discussion ---------- Add parsing of hexadecimal strings for PHP 7 | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #14086 | License | MIT | Doc PR | n/a PHP 7 does not handle the hexadecimal notation in is_numeric checks anymore, so the detection needs to be implemented explicitly. With this change, we should have a passing testsuite on PHP 7 Commits ------- e848040 Add parsing of hexadecimal strings for PHP 7
@fabpot should we remove the allow_failure for PHP 7 or not yet ? |
@stof: Yes, let's do that. |
PHP 7 does not handle the hexadecimal notation in is_numeric checks anymore, so the detection needs to be implemented explicitly.
With this change, we should have a passing testsuite on PHP 7