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.
This commit is contained in:
Marcin Wielgoszewski
2012-11-22 11:10:22 -05:00
parent 59dea188da
commit 18be26fc2a
+10 -13
View File
@@ -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):