Skip to content

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

Closed

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

Activity

  1. added a commit that references this issue on Dec 26, 2024
    d652d56
  2. linked a pull request that will close this issueFix ini quantity parsing bugs #17274on Dec 26, 2024
  3. added a commit that references this issue on Jan 9, 2025
    2c26772
  4. added 2 commits that reference this issue on Jan 9, 2025
    3eb79e1
    5d4707e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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