php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79934 CRLF-only line in heredoc causes parsing error
Submitted: 2020-08-05 18:20 UTC Modified: 2020-08-06 07:54 UTC
From: pevandenham at gmail dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 7.4.8 OS: Any
Private report: No CVE-ID: None
 [2020-08-05 18:20 UTC] pevandenham at gmail dot com
Description:
------------
A line that only contains CRLF (i.e. a whitespace-only or empty line on Windows) in the middle of a heredoc causes a parse error. This affects any PHP script that has CRLF line endings. 

To reproduce on e.g. Ubuntu, one can use the unix2dos program to convert the test script below to use CRLF and reproduce the bug: unix2dos bug.php && php bug.php

Test script:
---------------
<?php

$a = <<<HEREDOC
    a

    b
    HEREDOC;

var_dump($a);

Expected result:
----------------
string(4) "a

b"


Actual result:
--------------
Parse error: Invalid body indentation level (expecting an indentation level of at least 4) in /tmp/test.php on line 5


Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-08-05 18:34 UTC] pevandenham at gmail dot com
The following pull request has been associated:

Patch Name: Fix #79934: CRLF-only line in heredoc causes parsing error
On GitHub:  https://github.com/php/php-src/pull/5944
Patch:      https://github.com/php/php-src/pull/5944.patch
 [2020-08-06 07:54 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2020-08-06 10:04 UTC] nikic@php.net
Automatic comment on behalf of p.e.vandenham@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=06ade15528fa64acd9dea92b072a985793d1dcc1
Log: Fix #79934: CRLF-only line in heredoc causes parsing error
 [2020-08-06 10:04 UTC] nikic@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Sep 29 15:01:25 2020 UTC