Fix GH-14189: PHP Interactive shell input state incorrectly handles quoted heredoc literals.

Only `'` was handled, no handling case for `"` existed. Simply add it so
the heredoc tag is set up correctly.

Closes GH-14195.
This commit is contained in:
Niels Dossche 2024-05-10 15:53:04 +02:00
parent 15813d69a5
commit 217b753a3d
No known key found for this signature in database
GPG key ID: B8A8AD166DF0E2E5
3 changed files with 49 additions and 0 deletions

4
NEWS
View file

@ -6,6 +6,10 @@ PHP NEWS
. Fixed buffer limit on Windows, replacing read call usage by _read. . Fixed buffer limit on Windows, replacing read call usage by _read.
(David Carlier) (David Carlier)
- CLI:
. Fixed bug GH-14189 (PHP Interactive shell input state incorrectly handles
quoted heredoc literals.). (nielsdos)
- Core: - Core:
. Fixed bug GH-13970 (Incorrect validation of #[Attribute] flags type for . Fixed bug GH-13970 (Incorrect validation of #[Attribute] flags type for
non-compile-time expressions). (ilutov) non-compile-time expressions). (ilutov)

View file

@ -343,6 +343,7 @@ static int cli_is_valid_code(char *code, size_t len, zend_string **prompt) /* {{
case ' ': case ' ':
case '\t': case '\t':
case '\'': case '\'':
case '"':
break; break;
case '\r': case '\r':
case '\n': case '\n':

View file

@ -0,0 +1,44 @@
--TEST--
GH-14189 (PHP Interactive shell input state incorrectly handles quoted heredoc literals.)
--EXTENSIONS--
readline
--SKIPIF--
<?php
include "skipif.inc";
if (readline_info('done') === NULL) {
die ("skip need readline support");
}
?>
--FILE--
<?php
$php = getenv('TEST_PHP_EXECUTABLE');
// disallow console escape sequences that may break the output
putenv('TERM=VT100');
$code = <<<EOT
\$test = <<<"EOF"
foo
bar
baz
EOF;
echo \$test;
exit
EOT;
$code = escapeshellarg($code);
echo `echo $code | "$php" -a`, "\n";
?>
--EXPECT--
Interactive shell
php > $test = <<<"EOF"
<<< > foo
<<< > bar
<<< > baz
<<< > EOF;
php > echo $test;
foo
bar
baz
php > exit