Skip to content

Commit b06994b

Browse files
authored
Merge pull request #146 from twm/ne-plus-ultra
(Encoded)URL round-tripping of + in query
2 parents 5183099 + a9eba07 commit b06994b

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/hyperlink/_url.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def __nonzero__(self):
183183
_SCHEMELESS_PATH_DELIMS = _ALL_DELIMS - _SCHEMELESS_PATH_SAFE
184184
_FRAGMENT_SAFE = _UNRESERVED_CHARS | _PATH_SAFE | set(u"/?")
185185
_FRAGMENT_DELIMS = _ALL_DELIMS - _FRAGMENT_SAFE
186-
_QUERY_VALUE_SAFE = _UNRESERVED_CHARS | _FRAGMENT_SAFE - set(u"&+")
186+
_QUERY_VALUE_SAFE = _UNRESERVED_CHARS | _FRAGMENT_SAFE - set(u"&")
187187
_QUERY_VALUE_DELIMS = _ALL_DELIMS - _QUERY_VALUE_SAFE
188188
_QUERY_KEY_SAFE = _UNRESERVED_CHARS | _QUERY_VALUE_SAFE - set(u"=")
189189
_QUERY_KEY_DELIMS = _ALL_DELIMS - _QUERY_KEY_SAFE
@@ -931,9 +931,9 @@ class URL(object):
931931
https://example.com/hello/world
932932
933933
The constructor runs basic type checks. All strings are expected
934-
to be decoded (:class:`unicode` in Python 2). All arguments are
935-
optional, defaulting to appropriately empty values. A full list of
936-
constructor arguments is below.
934+
to be text (:class:`str` in Python 3, :class:`unicode` in Python 2). All
935+
arguments are optional, defaulting to appropriately empty values. A full
936+
list of constructor arguments is below.
937937
938938
Args:
939939
scheme: The text name of the scheme.
@@ -943,9 +943,9 @@ class URL(object):
943943
it is known. See the ``SCHEME_PORT_MAP`` and
944944
:func:`register_default_port` for more info.
945945
path: A tuple of strings representing the slash-separated parts of the
946-
path.
946+
path, each percent-encoded.
947947
query: The query parameters, as a dictionary or as an sequence of
948-
key-value pairs.
948+
percent-encoded key-value pairs.
949949
fragment: The fragment part of the URL.
950950
rooted: A rooted URL is one which indicates an absolute path.
951951
This is True on any URL that includes a host, or any relative URL

src/hyperlink/test/test_url.py

+2
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@
133133
"https://example.com/?a=%23", # hash in query param value
134134
"https://example.com/?a=%26", # ampersand in query param value
135135
"https://example.com/?a=%3D", # equals in query param value
136+
"https://example.com/?foo+bar=baz", # plus in query param name
137+
"https://example.com/?foo=bar+baz", # plus in query param value
136138
# double-encoded percent sign in all percent-encodable positions:
137139
"http://(%2525):(%2525)@example.com/(%2525)/?(%2525)=(%2525)#(%2525)",
138140
# colon in first part of schemeless relative url

0 commit comments

Comments
 (0)