Commit 6deffb43 authored by Jonas Schäfer's avatar Jonas Schäfer Committed by Link Mauve

Improve highlighing regex to deal with fancy nicknames

Nicknames which do not end and start on a word boundary or contain
regex metacharacters broke with the previous approach.

Fixes #3433.
parent 4b8c63d2
Pipeline #1656 passed with stages
in 2 minutes and 33 seconds
......@@ -1251,11 +1251,14 @@ class MucTab(ChatTab):
1, self.width, self.height - 2 - self.core.information_win_size -
Tab.tab_win_height(), 0)
def build_highlight_regex(self, nickname):
return re.compile(r"(^|\W)" + re.escape(nickname) + r"(\W|$)", re.I)
def is_highlight(self, txt, time, nickname, own_nick, highlight_on,
corrected=False):
highlighted = False
if (not time or corrected) and nickname and nickname != own_nick:
if re.search(r'\b' + own_nick.lower() + r'\b', txt.lower()):
if self.build_highlight_regex(own_nick).search(txt):
highlighted = True
else:
highlight_words = highlight_on.split(':')
......
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