Bug #71806 [Csd]: php_strip_whitespace() fails on some numerical values

From: Date: Sat, 12 Mar 2016 09:59:33 +0000
Subject: Bug #71806 [Csd]: php_strip_whitespace() fails on some numerical values
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-199779@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71806&edit=1 ID: 71806 Updated by: nikic@php.net Reported by: gregzem at inbox dot ru Summary: php_strip_whitespace() fails on some numerical values Status: Closed Type: Bug Package: Scripting Engine problem Operating System: ANY PHP Version: 7.0.4 Assigned To: nikic Block user comment: N Private report: N New Comment: To clarify, the reason why I'm suppressing the error is that our "lexy" functions are supposed to be robust and able to process code that may not be valid in the current version of PHP or may only be an excerpt of valid code. token_get_all() and the highlight_string()/highlight_file() functions already suppress lexer errors, so now php_strip_whitespace() does as well. Previous Comments: ------------------------------------------------------------------------ [2016-03-12 05:13:20] requinix@php.net To be clear, 0987654321 *isn't* a valid number: the leading 0 indicates octal and '9' and '8' are not allowed in octal. Trying to execute testfile.php (in PHP 7) will produce the parse error. http://php.net/manual/en/language.types.integer.php#language.types.integer.syntax > Warning > Prior to PHP 7, if an invalid digit was given in an octal integer (i.e. 8 or > 9), the rest of the number was ignored. Since PHP 7, a parse error is emitted. @nikic's fix only *suppresses* the error when running that code through php_strip_whitespace(). ------------------------------------------------------------------------ [2016-03-11 21:46:45] nikic@php.net Automatic comment on behalf of nikic Revision: http://git.php.net/?p=php-src.git;a=commit;h=02743f43c2de313e30320f2fb2d995937ce9881b Log: Fixed bug #71806 ------------------------------------------------------------------------ [2016-03-11 21:25:12] gregzem at inbox dot ru Description: ------------ If the source contains digits starting with 0, php_strip_whitespace() fails to process the source and produces the parser error. <?php echo 0987654321; ?> This source will generate the following error: PHP Parse error: Invalid numeric literal in testfile.php on line 2 Test script: --------------- testfile.php <?php echo 0987654321; ?> test.php: <?php $test = php_strip_whitespace('testfile.php'); ?> Expected result: ---------------- php_strip_whitespace processes the file without any errors. Actual result: -------------- php_strip_whitespace generates PHP Parse error: Invalid numeric literal in testfile.php on line 2 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=71806&edit=1

« previous php.bugs (#199779) next »