xref: /PHP-8.0/Zend/tests/bug79934.phpt (revision 06ade155)
1--TEST--
2Bug #79934: CRLF-only line in heredoc causes parsing error
3--DESCRIPTION--
4This test covers different variations of whitespace-only lines in heredoc strings.
5These whitespace-only lines should be ignored when stripping indentation.
6--FILE--
7<?php
8// lines with only CRLF should not cause a parse error
9eval("\$s1 = <<<HEREDOC\r\n    a\r\n\r\n    b\r\n    HEREDOC;");
10var_dump(addcslashes($s1, "\r\n"));
11
12// lines with only a LF should not cause a parse error
13eval("\$s2 = <<<HEREDOC\n    a\n\n    b\n    HEREDOC;");
14var_dump(addcslashes($s2, "\n"));
15
16// lines with only a CR should not cause a parse error
17eval("\$s3 = <<<HEREDOC\r    a\r\r    b\r    HEREDOC;");
18var_dump(addcslashes($s3, "\r"));
19
20// lines with only whitespace should not cause a parse error
21eval("\$s4 = <<<HEREDOC\r    a\r\n  \r\n    b\r    HEREDOC;");
22var_dump(addcslashes($s4, "\n\r"));
23
24?>
25--EXPECT--
26string(10) "a\r\n\r\nb"
27string(6) "a\n\nb"
28string(6) "a\r\rb"
29string(10) "a\r\n\r\nb"
30