degesch: fix highlight detection in colored text

This commit is contained in:
Přemysl Eric Janouch 2016-09-23 23:46:26 +02:00
parent 92a4d4b5a7
commit 4cefa5ab1b
Signed by: p
GPG Key ID: B715679E3A361BE6

View File

@ -5916,10 +5916,26 @@ irc_is_highlight (struct server *s, const char *message)
if (!s->irc_user)
return false;
// Strip formatting from the message so that it doesn't interfere
// with nickname detection (color sequences in particular)
struct formatter f;
formatter_init (&f, s->ctx, NULL);
formatter_parse_mirc (&f, message);
struct str stripped;
str_init (&stripped);
for (size_t i = 0; i < f.items_len; i++)
{
if (f.items[i].type == FORMATTER_ITEM_TEXT)
str_append (&stripped, f.items[i].text);
}
formatter_free (&f);
// Well, this is rather crude but it should make most users happy.
// Ideally we could do this at least in proper Unicode.
char *copy = xstrdup (message);
char *copy = irc_to_utf8 (stripped.str);
cstr_transform (copy, s->irc_tolower);
str_free (&stripped);
char *nick = xstrdup (s->irc_user->nickname);
cstr_transform (nick, s->irc_tolower);