Repository: mozilla/bleach

Issue:
Linkify incorrectly parses array arguments
Hi.
Library version up to 3.1.0 incorrectly parses array and object url parameters:
```python
from bleach import DEFAULT_CALLBACKS, Linker
text= 'http://test.com?array[]=1&params_in[]=2'
linker = Linker(url_re=linkifier.URL_RE, callbacks=DEFAULT_CALLBACKS, skip_tags=None, parse_email=False)
print(linker.linkify(text))
# prints: <a href="http://test.com?array" rel="nofollow">http://test.com?array</a>[]=1¶ms_in[]=2
```
As you see, url is split by [], loosing part of the link.

Discussion:

Patch:
diff --git a/bleach/linkifier.py b/bleach/linkifier.py
index 54a432e..8fcefb2 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(?<![@.])(?:(?:{0}):/{{0,3}}(?:(?:\w+:)?\w+@)?)?  # http://
         ([\w-]+\.)+(?:{1})(?:\:[0-9]+)?(?!\.\w)\b   # xx.yy.tld(:##)?
-        (?:[/?][^\s\{{\}}\|\\\^\[\]`<>"]*)?
-            # /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))


Test patch:
diff --git a/tests/test_linkify.py b/tests/test_linkify.py
index 4cc01a6..0920c47 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&params_in[]=2") == (
+        '<a href="http://test.com?array[]=1&amp;params_in[]=2" '
+        + 'rel="nofollow">http://test.com?array[]=1&amp;params_in[]=2</a>'
+    )
+
+
 def test_link_query():
     assert (
         linkify("http://xx.com/?test=win")