Daniel Brötzmann pushed to branch master at gajim / gajim
Commits: 0dbbf715 by André Apitzsch at 2022-03-04T22:07:10+01:00 Fix highlighting of email addresses
Fixes #10788.
- - - - -
2 changed files:
- gajim/common/styling.py - test/no_gui/test_styling.py
Changes:
===================================== gajim/common/styling.py ===================================== @@ -46,7 +46,7 @@ URI_RX = r'((?P<protocol>[\w-]+://?|www[.])[\S()<>]+?(?=[,]?(\s|\Z)+))' URI_RX = re.compile(URI_RX)
-ADDRESS_RX = r'(\b(?P<protocol>(xmpp|mailto)+:)?[\w-]*@(.*?.)+[\w]+([?].*?(?=([\s),]|$)))?)' +ADDRESS_RX = r'(\b(?P<protocol>(xmpp|mailto):)?[\w-]*@(\w*?.)+[\w]+([?].*?(?=([\s),]|$)))?)' ADDRESS_RX = re.compile(ADDRESS_RX)
EMOJI_RX = emoji_data.get_regex()
===================================== test/no_gui/test_styling.py ===================================== @@ -325,6 +325,14 @@ EMAILS = [ 'asd@asd.at', 'asd@asd.asd.at', + 'mailto:foo@bar.com.uk', +] + +EMAILS_WITH_TEXT = [ + ('write to my email mailto:foo@bar.com.uk (but not to mailto:bar@foo.com)', + ['mailto:foo@bar.com.uk', 'mailto:bar@foo.com']), + ('write to my email mailtomailto:foo@bar.com.uk (but not to mailto:bar@foo.com)', + ['foo@bar.com.uk', 'mailto:bar@foo.com']), ]
@@ -360,6 +368,13 @@ def test_emails(self): end = match.end() self.assertTrue(email[start:end] == email)
+ def test_emails_with_text(self): + for text, result in EMAILS_WITH_TEXT: + match = ADDRESS_RX.findall(text) + self.assertIsNotNone(match) + for i, res in enumerate(result): + self.assertTrue(match[i][0] == res) + def test_url_with_text(self): for text, result in URL_WITH_TEXT: match = URI_RX.search(text)
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/0dbbf715fc2196cff67cd55fc2bd39b9e...