From 4cefa5ab1b5c89583d66c466bea00bc58c8dddfd Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Fri, 23 Sep 2016 23:46:26 +0200 Subject: degesch: fix highlight detection in colored text --- degesch.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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); -- cgit v1.2.3-70-g09d2