Patch for an Issue #203

This commit is contained in:
Miroslav Stampar 2012-10-15 16:23:41 +02:00
parent e440b096c5
commit 9aba690a60
2 changed files with 10 additions and 4 deletions

View File

@ -1962,7 +1962,7 @@ def extractErrorMessage(page):
return retVal return retVal
def urldecode(value, encoding=None): def urldecode(value, encoding=None, onlyPrintable=True):
result = None result = None
if value: if value:
@ -1972,7 +1972,13 @@ def urldecode(value, encoding=None):
except ValueError: except ValueError:
pass pass
finally: finally:
result = urllib.unquote_plus(value) if onlyPrintable:
def _(match):
char = chr(ord(match.group(1).decode("hex")))
return char if char in string.printable.replace("&", "") else match.group(0)
result = re.sub("%([0-9a-fA-F]{2})", _, value)
else:
result = urllib.unquote_plus(value)
if isinstance(result, str): if isinstance(result, str):
result = unicode(result, encoding or UNICODE_ENCODING, "replace") result = unicode(result, encoding or UNICODE_ENCODING, "replace")

View File

@ -1339,10 +1339,10 @@ def __cleanupOptions():
if re.search(r'%[0-9a-f]{2}', conf.data, re.I): if re.search(r'%[0-9a-f]{2}', conf.data, re.I):
original = conf.data original = conf.data
class _(unicode): pass class _(unicode): pass
conf.data = _(urldecode(conf.data) if conf.data and urlencode(DEFAULT_GET_POST_DELIMITER, None) not in conf.data else conf.data) conf.data = _(urldecode(conf.data))
setattr(conf.data, UNENCODED_ORIGINAL_VALUE, original) setattr(conf.data, UNENCODED_ORIGINAL_VALUE, original)
else: else:
conf.data = urldecode(conf.data) if conf.data and urlencode(DEFAULT_GET_POST_DELIMITER, None) not in conf.data else conf.data conf.data = urldecode(conf.data)
if conf.os: if conf.os:
conf.os = conf.os.capitalize() conf.os = conf.os.capitalize()