summaryrefslogtreecommitdiff
path: root/degesch.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2016-09-23 23:46:26 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2016-09-23 23:46:26 +0200
commit4cefa5ab1b5c89583d66c466bea00bc58c8dddfd (patch)
tree408d425fe9bf87458489655165940738077fe80b /degesch.c
parent92a4d4b5a7b276ab7a606d876d03fb346f4ceda4 (diff)
downloadxK-4cefa5ab1b5c89583d66c466bea00bc58c8dddfd.tar.gz
xK-4cefa5ab1b5c89583d66c466bea00bc58c8dddfd.tar.xz
xK-4cefa5ab1b5c89583d66c466bea00bc58c8dddfd.zip
degesch: fix highlight detection in colored text
Diffstat (limited to 'degesch.c')
-rw-r--r--degesch.c18
1 files changed, 17 insertions, 1 deletions
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);