Skip to content

Fix bug #81280 refuse to allow unicode chars in prompts #7333

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 2 commits 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
12 changes: 11 additions & 1 deletion ext/readline/readline_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ static zend_string *cli_get_prompt(char *block, char prompt) /* {{{ */
{
smart_str retval = {0};
char *prompt_spec = CLIR_G(prompt) ? CLIR_G(prompt) : DEFAULT_PROMPT;
bool unicode_warned = false;

do {
if (*prompt_spec == '\\') {
Expand Down Expand Up @@ -193,7 +194,16 @@ static zend_string *cli_get_prompt(char *block, char prompt) /* {{{ */
prompt_spec = prompt_end;
}
} else {
smart_str_appendc(&retval, *prompt_spec);
if (!(*prompt_spec & 0x80)) {
smart_str_appendc(&retval, *prompt_spec);
} else {
if (!unicode_warned) {
zend_error(E_WARNING,
"prompt contains unsupported unicode characters");
unicode_warned = true;
}
smart_str_appendc(&retval, '?');
}
}
} while (++prompt_spec && *prompt_spec);
smart_str_0(&retval);
Expand Down
17 changes: 17 additions & 0 deletions sapi/phpdbg/phpdbg_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,23 @@ PHPDBG_API const char *phpdbg_get_prompt(void) /* {{{ */
return PHPDBG_G(prompt)[1];
}

uint32_t pos = 0,
end = strlen(PHPDBG_G(prompt)[0]);
bool unicode_warned = false;

while (pos < end) {
if (PHPDBG_G(prompt)[0][pos] & 0x80) {
PHPDBG_G(prompt)[0][pos] = '?';

if (!unicode_warned) {
zend_error(E_WARNING,
"prompt contains unsupported unicode characters");
unicode_warned = true;
}
}
pos++;
}

/* create cached prompt */
#ifndef HAVE_LIBEDIT
/* TODO: libedit doesn't seems to support coloured prompt */
Expand Down