mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Fix bug #81280 refuse to allow unicode chars in prompts
This commit is contained in:
parent
3a4d0d360d
commit
a2e051921a
3 changed files with 30 additions and 1 deletions
2
NEWS
2
NEWS
|
@ -5,6 +5,8 @@ PHP NEWS
|
|||
- Core:
|
||||
. Fixed bug #81342 (New ampersand token parsing depends on new line after it).
|
||||
(Nikita)
|
||||
. Fixed bug #81280 (Unicode characters in cli.prompt causes segfault).
|
||||
(krakjoe)
|
||||
|
||||
- Date:
|
||||
. Fixed bug #79580 (date_create_from_format misses leap year). (Derick)
|
||||
|
|
|
@ -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 == '\\') {
|
||||
|
@ -193,7 +194,16 @@ static zend_string *cli_get_prompt(char *block, char prompt) /* {{{ */
|
|||
prompt_spec = prompt_end;
|
||||
}
|
||||
} else {
|
||||
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);
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue