Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ext/readline/readline_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ static int cli_is_valid_code(char *code, size_t len, zend_string **prompt) /* {{
case ' ':
case '\t':
case '\'':
case '"':
break;
case '\r':
case '\n':
Expand Down
44 changes: 44 additions & 0 deletions sapi/cli/tests/gh14189.phpt
Original file line number Diff line number Diff line change
@@ -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
Loading