Skip to content
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

ini_parse_quantity() fails to emit warning for 0x+0 #16886

Open
plstand opened this issue Nov 21, 2024 · 0 comments
Open

ini_parse_quantity() fails to emit warning for 0x+0 #16886

plstand opened this issue Nov 21, 2024 · 0 comments

Comments

@plstand
Copy link
Contributor

plstand commented Nov 21, 2024

Description

zend_ini_consume_quantity_prefix(), when a leading zero that is not part of a base prefix is found, incorrectly returns a pointer to the first character processed, rather than to the zero. This means that ini_parse_quantity() emits no warning for invalid input that matches the regex ^\s*[+-]?0[xXoObB](?:\s+[+-]?|[+-])0\s*$, where \s is any character listed in zend_is_whitespace().

The following code:

<?php
echo ini_parse_quantity('0x 0'), "\n";
echo ini_parse_quantity('0x+0'), "\n";
echo ini_parse_quantity('0x-0'), "\n";

Resulted in this output:

0
0
0

But I expected this output instead:


Warning: Invalid quantity "0x 0": no digits after base prefix, interpreting as "0" for backwards compatibility in /home/ki/Documents/Scratchpad/test_parse_quantity_prefixes.php on line 2
0

Warning: Invalid quantity "0x+0": no digits after base prefix, interpreting as "0" for backwards compatibility in /home/ki/Documents/Scratchpad/test_parse_quantity_prefixes.php on line 3
0

Warning: Invalid quantity "0x-0": no digits after base prefix, interpreting as "0" for backwards compatibility in /home/ki/Documents/Scratchpad/test_parse_quantity_prefixes.php on line 4
0

PHP Version

PHP 8.5.0-dev

Operating System

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant