Skip to content

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

Closed
@plstand

Description

@plstand

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions