Skip to content

Fix #79934: CRLF-only line in heredoc causes parsing error #5944

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Zend/tests/bug79934.phpt
Original file line number Diff line number Diff line change
@@ -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"
Loading