summaryrefslogtreecommitdiff
path: root/requests
diff options
context:
space:
mode:
authorCory Benfield <lukasaoz@gmail.com>2013-08-02 12:29:23 +0100
committerCory Benfield <lukasaoz@gmail.com>2013-08-02 12:29:23 +0100
commit5a26241287162ff592c81dbfbbd013e309c85c05 (patch)
treee7db9ab4c2b5102b46c54db0045056e398262f8a /requests
parentbd1f1404a0b38837f8f8b3eaf5f27d783bb29362 (diff)
downloadpython-requests-5a26241287162ff592c81dbfbbd013e309c85c05.tar.gz
Better percent-escape exception.
Diffstat (limited to 'requests')
-rw-r--r--requests/utils.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/requests/utils.py b/requests/utils.py
index 347f2be1..00da2669 100644
--- a/requests/utils.py
+++ b/requests/utils.py
@@ -25,7 +25,7 @@ from .compat import (quote, urlparse, bytes, str, OrderedDict, urlunparse,
is_py2, is_py3, builtin_str, getproxies, proxy_bypass)
from .cookies import RequestsCookieJar, cookiejar_from_dict
from .structures import CaseInsensitiveDict
-from .exceptions import MissingSchema
+from .exceptions import MissingSchema, InvalidURL
_hush_pyflakes = (RequestsCookieJar,)
@@ -363,7 +363,11 @@ def unquote_unreserved(uri):
for i in range(1, len(parts)):
h = parts[i][0:2]
if len(h) == 2 and h.isalnum():
- c = chr(int(h, 16))
+ try:
+ c = chr(int(h, 16))
+ except ValueError:
+ raise InvalidURL("Invalid percent-escape sequence: '%s'" % h)
+
if c in UNRESERVED_SET:
parts[i] = c + parts[i][2:]
else: