diff options
Diffstat (limited to 'Zend')
-rw-r--r-- | Zend/tests/bug79934.phpt | 29 | ||||
-rw-r--r-- | Zend/zend_language_scanner.l | 1 |
2 files changed, 30 insertions, 0 deletions
diff --git a/Zend/tests/bug79934.phpt b/Zend/tests/bug79934.phpt new file mode 100644 index 0000000000..a983cb742d --- /dev/null +++ b/Zend/tests/bug79934.phpt @@ -0,0 +1,29 @@ +--TEST-- +Bug #79934: CRLF-only line in heredoc causes parsing error +--DESCRIPTION-- +This test covers different variations of whitespace-only lines in heredoc strings. +These whitespace-only lines should be ignored when stripping indentation. +--FILE-- +<?php +// lines with only CRLF should not cause a parse error +eval("\$s1 = <<<HEREDOC\r\n a\r\n\r\n b\r\n HEREDOC;"); +var_dump(addcslashes($s1, "\r\n")); + +// lines with only a LF should not cause a parse error +eval("\$s2 = <<<HEREDOC\n a\n\n b\n HEREDOC;"); +var_dump(addcslashes($s2, "\n")); + +// lines with only a CR should not cause a parse error +eval("\$s3 = <<<HEREDOC\r a\r\r b\r HEREDOC;"); +var_dump(addcslashes($s3, "\r")); + +// lines with only whitespace should not cause a parse error +eval("\$s4 = <<<HEREDOC\r a\r\n \r\n b\r HEREDOC;"); +var_dump(addcslashes($s4, "\n\r")); + +?> +--EXPECT-- +string(10) "a\r\n\r\nb" +string(6) "a\n\nb" +string(6) "a\r\rb" +string(10) "a\r\n\r\nb" diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index 92fa9b7230..db493211e2 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -1118,6 +1118,7 @@ static const char *next_newline(const char *str, const char *end, size_t *newlin for (; str < end; str++) { if (*str == '\r') { *newline_len = str + 1 < end && *(str + 1) == '\n' ? 2 : 1; + return str; } else if (*str == '\n') { *newline_len = 1; return str; |