Skip to content

Commit 217b753

Browse files
committed
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.
1 parent 15813d6 commit 217b753

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ PHP NEWS
66
. Fixed buffer limit on Windows, replacing read call usage by _read.
77
(David Carlier)
88

9+
- CLI:
10+
. Fixed bug GH-14189 (PHP Interactive shell input state incorrectly handles
11+
quoted heredoc literals.). (nielsdos)
12+
913
- Core:
1014
. Fixed bug GH-13970 (Incorrect validation of #[Attribute] flags type for
1115
non-compile-time expressions). (ilutov)

ext/readline/readline_cli.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ static int cli_is_valid_code(char *code, size_t len, zend_string **prompt) /* {{
343343
case ' ':
344344
case '\t':
345345
case '\'':
346+
case '"':
346347
break;
347348
case '\r':
348349
case '\n':

sapi/cli/tests/gh14189.phpt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
--TEST--
2+
GH-14189 (PHP Interactive shell input state incorrectly handles quoted heredoc literals.)
3+
--EXTENSIONS--
4+
readline
5+
--SKIPIF--
6+
<?php
7+
include "skipif.inc";
8+
if (readline_info('done') === NULL) {
9+
die ("skip need readline support");
10+
}
11+
?>
12+
--FILE--
13+
<?php
14+
$php = getenv('TEST_PHP_EXECUTABLE');
15+
16+
// disallow console escape sequences that may break the output
17+
putenv('TERM=VT100');
18+
19+
$code = <<<EOT
20+
\$test = <<<"EOF"
21+
foo
22+
bar
23+
baz
24+
EOF;
25+
echo \$test;
26+
exit
27+
EOT;
28+
29+
$code = escapeshellarg($code);
30+
echo `echo $code | "$php" -a`, "\n";
31+
?>
32+
--EXPECT--
33+
Interactive shell
34+
35+
php > $test = <<<"EOF"
36+
<<< > foo
37+
<<< > bar
38+
<<< > baz
39+
<<< > EOF;
40+
php > echo $test;
41+
foo
42+
bar
43+
baz
44+
php > exit

0 commit comments

Comments
 (0)