Commit ae7e7128 authored by Alice Mitchell's avatar Alice Mitchell

Handle escape sequences that turn out not to be valid

parent 15a0fb44
......@@ -54,6 +54,7 @@ int colour(const char *input, char *output, int outlen)
{
int consume = 0;
if (outlen) output[0] = '\0';
/* original colour mode */
if (*input == 033) {
char text[3];
......
......@@ -1086,11 +1086,15 @@ void display_message(const char *text, int beeps, int newline)
if (UseRL && disable_rl(1)) charcount = 0;
while (*text) {
int skip = 0;
if (*text == 033 || *text == '&') {
/* escape sequence, skip next two chars */
text += colour(text, colr, sizeof(colr));
/* possible escape sequence */
skip = colour(text, colr, sizeof(colr));
}
if (skip) {
/* an escape sequence to be substituted */
text += skip;
if (colr[0] && !s_colouroff(user)) {
for (int j = 0; j < strlen(colr); j++)
outline[olen++] = colr[j];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment