From: Marcin Wielgoszewski Date: Thu, 22 Nov 2012 16:10:22 +0000 (-0500) Subject: Back to issue #630, .isalnum() was sufficient in addressing the issue. X-Git-Tag: v1.0.0~104^2~8^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=18be26fc2a7f8d41b691762d826f235ae04f24fd;p=services%2Fpython-requests.git Back to issue #630, .isalnum() was sufficient in addressing the issue. Adding a try/except block just masks any issues that are raised here, issues that the developer should definitely be made aware of. --- diff --git a/requests/utils.py b/requests/utils.py index b3d33f4..df25126 100644 --- a/requests/utils.py +++ b/requests/utils.py @@ -473,21 +473,18 @@ def unquote_unreserved(uri): """Un-escape any percent-escape sequences in a URI that are unreserved characters. This leaves all reserved, illegal and non-ASCII bytes encoded. """ - try: - parts = uri.split('%') - for i in range(1, len(parts)): - h = parts[i][0:2] - if len(h) == 2 and h.isalnum(): - c = chr(int(h, 16)) - if c in UNRESERVED_SET: - parts[i] = c + parts[i][2:] - else: - parts[i] = '%' + parts[i] + parts = uri.split('%') + for i in range(1, len(parts)): + h = parts[i][0:2] + if len(h) == 2 and h.isalnum(): + c = chr(int(h, 16)) + if c in UNRESERVED_SET: + parts[i] = c + parts[i][2:] else: parts[i] = '%' + parts[i] - return ''.join(parts) - except ValueError: - return uri + else: + parts[i] = '%' + parts[i] + return ''.join(parts) def requote_uri(uri):