[php-src] Issue #14189: PHP CLI input state incorrectly handles quoted heredoc literals.

From: Date: Fri, 10 May 2024 03:01:49 +0000
Subject: [php-src] Issue #14189: PHP CLI input state incorrectly handles quoted heredoc literals.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-246887@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/14189 Author: MorganLOCode ### Description In the command line interface, starting a heredoc statement puts the CLI into a state (indicated by prefixing each input line with <<< instead of php) where subsequent lines are part of the string literal, until the delimiter is entered. But if the opening delimiter is double-quoted the input state remains stuck in <<< until a double-quoted delimiter is encountered, and then execution resumes. ```text Interactive shell php > $I = 'You'; php > $foo = <<<"EOF" <<< > How do $I <<< > compare? <<< > EOF; <<< > $k = 45+19; <<< > echo $foo; <<< > echo " When I'm $k?"; <<< > "EOF"; How do You compare? When I'm 64? ``` What I would expect is the same as if double-quotes had not been used: parsing and execution resumes following the closing delimiter, and doesn't require the quoted closing delimiter to unwedge the input state: ```text Interactive shell php > $I = 'You'; php > $foo = <<< EOF <<< > How do $I <<< > compare? <<< > EOF; php > $k = 45+19; php > echo $foo; How do You compare? php > echo " When I'm $k?"; When I'm 64? php > ``` For the record, single-quoted nowdoc strings behave as expected: ```text Interactive shell php > $I = 'You'; php > $foo = <<< 'EOF' <<< > How do $I <<< > compare? <<< > EOF; php > $k = 45+19; php > echo $foo; How do $I compare? php > echo " When I'm $k?"; When I'm 64? php > ``` ### PHP Version PHP 8.3.7 (also present in 8.3.6). ### Operating System Windows 10

« previous php.bugs (#246887) next »