diff --git a/lib/core/common.py b/lib/core/common.py index 302978bff..4e5f6b5a9 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -1962,7 +1962,7 @@ def extractErrorMessage(page): return retVal -def urldecode(value, encoding=None, onlyPrintable=True): +def urldecode(value, encoding=None, convall=False): result = None if value: @@ -1972,13 +1972,14 @@ def urldecode(value, encoding=None, onlyPrintable=True): except ValueError: pass finally: - 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: + if convall: result = urllib.unquote_plus(value) + else: + def _(match): + charset = string.printable.replace("&", "") + char = chr(ord(match.group(1).decode("hex"))) + return char if char in charset else match.group(0) + result = re.sub("%([0-9a-fA-F]{2})", _, value) if isinstance(result, str): result = unicode(result, encoding or UNICODE_ENCODING, "replace")