Fix #79934: CRLF-only line in heredoc causes parsing error#5944
Fix #79934: CRLF-only line in heredoc causes parsing error#5944pevdh wants to merge 1 commit intophp:PHP-7.3from
Conversation
|
Bug reference: https://bugs.php.net/bug.php?id=79934 I'm not sure how to create a test case for this bug. This is my first time contributing to php-src - let me know if I need to change anything. |
|
Also, while investigating this bug I came across |
I think that might actually be the only bug here. Does fixing that function also resolve this problem? For the test, you'll probably want to use |
22acc70 to
b185b4c
Compare
|
That does seem to fix it. I changed the commit to fix |
Zend/tests/bug79934.phpt
Outdated
| --FILE-- | ||
| <?php | ||
| eval("\$s = <<<HEREDOC\r\n a\r\n\r\n b\r\n HEREDOC;"); | ||
| var_dump($s); |
There was a problem hiding this comment.
I would suggest to add variations with \n and \r as well and use something like addcslashes( for the output, so we see the linebreaks more explicitly.
There was a problem hiding this comment.
I updated the test to include cases with "\n", "\r" and both "\r\n" as well as a whitespace-only line.
Fixes the function `next_newline()` in zend_language_scanner.l. The function now correctly returns a newline_len of 2 for "\r\n".
In
strip_multiline_string_indentation()(Zend/zend_language_scanner.l)the case that is supposed to ignore whitespace-only lines now correctly
handles CRLF-only lines.