diff --git a/degesch.c b/degesch.c index f56eb12..9d57abb 100644 --- a/degesch.c +++ b/degesch.c @@ -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);