Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
c8f9bbdb
by lovetox at 2022-06-19T23:51:31+02:00
-
be62995e
by lovetox at 2022-06-20T00:20:29+02:00
-
03033dfa
by lovetox at 2022-06-20T00:21:05+02:00
-
6df045ce
by lovetox at 2022-06-20T00:21:08+02:00
2 changed files:
Changes:
| ... | ... | @@ -43,11 +43,13 @@ |
| 43 | 43 | BLOCK_NESTED_RX = re.compile(PRE_NESTED_RX + '|' + QUOTE_RX, re.S | re.M)
|
| 44 | 44 | UNQUOTE_RX = re.compile(r'^> |^>', re.M)
|
| 45 | 45 | |
| 46 | -URI_RX = r'((?P<protocol>[\w-]+://?|www[.])[\S()<>]+?(?=[,]?(\s|\Z)+))'
|
|
| 47 | -URI_RX = re.compile(URI_RX)
|
|
| 46 | +URI_RX = r'(?P<uri>([\w-]+://|www[.])[\S()<>]+?(?=[,>]?(\s|\Z)+))'
|
|
| 47 | +ADDRESS_RX = r'(?P<address>\b((xmpp|mailto):)?[\w-]*@([\w-]*?\.)+[\w]+([\?].*?(?=([\s\),]|$)))?)' # noqa: E501
|
|
| 48 | +URI_ADDRESS_RX = URI_RX + '|' + ADDRESS_RX
|
|
| 48 | 49 | |
| 49 | -ADDRESS_RX = r'(\b(?P<protocol>(xmpp|mailto):)?[\w-]*@(\w*?\.)+[\w]+([\?].*?(?=([\s\),]|$)))?)' # noqa: E501
|
|
| 50 | +URI_RX = re.compile(URI_RX)
|
|
| 50 | 51 | ADDRESS_RX = re.compile(ADDRESS_RX)
|
| 52 | +URI_ADDRESS_RX = re.compile(URI_ADDRESS_RX)
|
|
| 51 | 53 | |
| 52 | 54 | EMOJI_RX = emoji_data.get_regex()
|
| 53 | 55 | EMOJI_RX = re.compile(EMOJI_RX)
|
| ... | ... | @@ -319,12 +321,8 @@ def make(match: Match[str], is_address: bool) -> BaseUri: |
| 319 | 321 | offset_bytes,
|
| 320 | 322 | is_address)
|
| 321 | 323 | |
| 322 | - for match in URI_RX.finditer(line):
|
|
| 323 | - uri = make(match, False)
|
|
| 324 | - uris.append(uri)
|
|
| 325 | - |
|
| 326 | - for match in ADDRESS_RX.finditer(line):
|
|
| 327 | - uri = make(match, True)
|
|
| 324 | + for match in URI_ADDRESS_RX.finditer(line):
|
|
| 325 | + uri = make(match, bool(match.group('address')))
|
|
| 328 | 326 | uris.append(uri)
|
| 329 | 327 | |
| 330 | 328 | return uris
|
| ... | ... | @@ -325,6 +325,8 @@ |
| 325 | 325 | EMAILS = [
|
| 326 | 326 | 'asd@asd.at',
|
| 327 | 327 | 'asd@asd.asd.at',
|
| 328 | + 'asd@asd.asd-asd.at',
|
|
| 329 | + 'asd-asd@asd.asdasd.at',
|
|
| 328 | 330 | 'mailto:foo@bar.com.uk',
|
| 329 | 331 | ]
|
| 330 | 332 | |
| ... | ... | @@ -339,6 +341,7 @@ |
| 339 | 341 | URL_WITH_TEXT = [
|
| 340 | 342 | ('see this http://userid@example.com/ link', 'http://userid@example.com/'),
|
| 341 | 343 | ('see this http://userid@example.com/, and ..', 'http://userid@example.com/'),
|
| 344 | + ('<http://userid@example.com/>', 'http://userid@example.com/'),
|
|
| 342 | 345 | ]
|
| 343 | 346 | |
| 344 | 347 | XMPP_URIS = [
|
| ... | ... | @@ -392,6 +395,5 @@ def test_xmpp_uris(self): |
| 392 | 395 | self.assertTrue(text[start:end] == result)
|
| 393 | 396 | |
| 394 | 397 | |
| 395 | - |
|
| 396 | 398 | if __name__ == "__main__":
|
| 397 | 399 | unittest.main() |