diff --git a/ext/readline/readline_cli.c b/ext/readline/readline_cli.c index 7a0fe78595e5b..8bf5d23df75f7 100644 --- a/ext/readline/readline_cli.c +++ b/ext/readline/readline_cli.c @@ -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 { - 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); diff --git a/sapi/phpdbg/phpdbg_utils.c b/sapi/phpdbg/phpdbg_utils.c index 272715654ebf2..0e46936fc627e 100644 --- a/sapi/phpdbg/phpdbg_utils.c +++ b/sapi/phpdbg/phpdbg_utils.c @@ -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 */