M src/wiki/plugins/links/mdx/urlize.py => src/wiki/plugins/links/mdx/urlize.py +1 -1
@@ 63,7 63,7 @@ URLIZE_RE = (
r'(?P<host>' # begin host identifier group
r'[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}|' # IPv4, match before FQDN
- r'\[?[A-F0-9]{1,4}:([A-F0-9]{1,4}:){6}[A-F0-9]{1,4}\]?|' # IPv6, full form
+ r'\[?([A-F0-9]{1,4}:){7}([A-F0-9]{1,4})\]?|' # IPv6, full form
r'\[?:(:[A-F0-9]{1,4}){1,6}\]?|' # IPv6, leading zeros removed
r'([A-F0-9]{1,4}:){1,6}:([A-F0-9]{1,4}){1,6}|' # IPv6, zeros in middle removed.
r'\[?([A-F0-9]{1,4}:){1,6}:\]?|' # IPv6, trailing zeros removed
M tests/plugins/links/test_urlize.py => tests/plugins/links/test_urlize.py +31 -0
@@ 152,6 152,12 @@ FIXTURE_NEGATIVE_MATCHES = [
'<p>.example .com</p>'
),
+ # localhost as part of another word.
+ (
+ 'localhosts',
+ '<p>localhosts</p>'
+ ),
+
# Invalid FQDNs.
(
'example-.com',
@@ 165,6 171,31 @@ FIXTURE_NEGATIVE_MATCHES = [
'my.-example.com',
'<p>my.-example.com</p>'
),
+
+ # Invalid IPv6 patterns.
+ (
+ '1:2:3:4:5:6:7:8:a', # Use :a, because using a number would match as optional port
+ '<p>1:2:3:4:5:6:7:8:a</p>',
+ ),
+ (
+ '1::2::3',
+ '<p>1::2::3</p>',
+ ),
+ (
+ '::::1',
+ '<p>::::1</p>',
+ ),
+ (
+ '1::::',
+ '<p>1::::</p>',
+ ),
+
+ # Invalid IPv4 patterns.
+ (
+ '1.2.3.4.5',
+ '<p>1.2.3.4.5</p>',
+ ),
+
]