summaryrefslogtreecommitdiff
path: root/Zend/zend_operators.c
diff options
context:
space:
mode:
authorAndrea Faulds <ajf@ajf.me>2020-06-24 15:05:58 +0200
committerGeorge Peter Banyard <girgias@php.net>2020-07-29 02:22:38 +0100
commitf759936591c08d9bff6ab707f2f8c192f61b5bf1 (patch)
tree9955533f54b7246cd2c4fd250050ea0f509e4c1f /Zend/zend_operators.c
parent99ee73e6a94c847cee7130928cc3b6acddece904 (diff)
downloadphp-git-f759936591c08d9bff6ab707f2f8c192f61b5bf1.tar.gz
Permit trailing whitespace in numeric strings
This is part 1 of the 'Saner Numeric Strings' RFC: https://wiki.php.net/rfc/saner-numeric-strings
Diffstat (limited to 'Zend/zend_operators.c')
-rw-r--r--Zend/zend_operators.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c
index a468962491..f0c17ea0d3 100644
--- a/Zend/zend_operators.c
+++ b/Zend/zend_operators.c
@@ -3052,11 +3052,18 @@ process_double:
}
if (ptr != str + length) {
- if (!allow_errors) {
- return 0;
+ const char *endptr = ptr;
+ while (*endptr == ' ' || *endptr == '\t' || *endptr == '\n' || *endptr == '\r' || *endptr == '\v' || *endptr == '\f') {
+ endptr++;
+ length--;
}
- if (allow_errors == -1) {
- zend_error(E_NOTICE, "A non well formed numeric value encountered");
+ if (ptr != str + length) {
+ if (!allow_errors) {
+ return 0;
+ }
+ if (allow_errors == -1) {
+ zend_error(E_NOTICE, "A non well formed numeric value encountered");
+ }
if (EG(exception)) {
return 0;
}