diff --git a/bleach/linkifier.py b/bleach/linkifier.py index 54a432e1..8fcefb2c 100644 --- a/bleach/linkifier.py +++ b/bleach/linkifier.py @@ -45,8 +45,8 @@ def build_url_re(tlds=TLDS, protocols=html5lib_shim.allowed_protocols): r"""\(* # Match any opening parentheses. \b(?"]*)? - # /path/zz (excluding "unsafe" chars from RFC 1738, + (?:[/?][^\s\{{\}}\|\\\^`<>"]*)? + # /path/zz (excluding "unsafe" chars from RFC 3986, # except for # and ~, which happen in practice) """.format( "|".join(sorted(protocols)), "|".join(sorted(tlds)) diff --git a/tests/test_linkify.py b/tests/test_linkify.py index 4cc01a6f..0920c470 100644 --- a/tests/test_linkify.py +++ b/tests/test_linkify.py @@ -300,6 +300,14 @@ def test_link_ftp(): ) +def test_link_with_qs_with_array(): + """Test that urls pick up [] in querystring""" + assert linkify("http://test.com?array[]=1¶ms_in[]=2") == ( + 'http://test.com?array[]=1&params_in[]=2' + ) + + def test_link_query(): assert ( linkify("http://xx.com/?test=win")