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 = [
'[email protected]',
'[email protected]',
+ 'mailto:[email protected]',
+]
+
+EMAILS_WITH_TEXT = [
+ ('write to my email mailto:[email protected] (but not to
mailto:[email protected])',
+ ['mailto:[email protected]', 'mailto:[email protected]']),
+ ('write to my email mailtomailto:[email protected] (but not to
mailto:[email protected])',
+ ['[email protected]', 'mailto:[email protected]']),
]
@@ -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/0dbbf715fc2196cff67cd55fc2bd39b9e5dc5bf9
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/0dbbf715fc2196cff67cd55fc2bd39b9e5dc5bf9
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits