Skip to content

Commit c4a4eba

Browse files
committed
Fix linkify with arrays in querystring (#436)
1 parent 11d8c9b commit c4a4eba

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

bleach/linkifier.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ def build_url_re(tlds=TLDS, protocols=html5lib_shim.allowed_protocols):
4545
r"""\(* # Match any opening parentheses.
4646
\b(?<![@.])(?:(?:{0}):/{{0,3}}(?:(?:\w+:)?\w+@)?)? # http://
4747
([\w-]+\.)+(?:{1})(?:\:[0-9]+)?(?!\.\w)\b # xx.yy.tld(:##)?
48-
(?:[/?][^\s\{{\}}\|\\\^\[\]`<>"]*)?
49-
# /path/zz (excluding "unsafe" chars from RFC 1738,
48+
(?:[/?][^\s\{{\}}\|\\\^`<>"]*)?
49+
# /path/zz (excluding "unsafe" chars from RFC 3986,
5050
# except for # and ~, which happen in practice)
5151
""".format(
5252
"|".join(sorted(protocols)), "|".join(sorted(tlds))

tests/test_linkify.py

+8
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,14 @@ def test_link_ftp():
300300
)
301301

302302

303+
def test_link_with_qs_with_array():
304+
"""Test that urls pick up [] in querystring"""
305+
assert linkify("http://test.com?array[]=1&params_in[]=2") == (
306+
'<a href="http://test.com?array[]=1&amp;params_in[]=2" '
307+
+ 'rel="nofollow">http://test.com?array[]=1&amp;params_in[]=2</a>'
308+
)
309+
310+
303311
def test_link_query():
304312
assert (
305313
linkify("http://xx.com/?test=win")

0 commit comments

Comments
 (0)