(value, encoding=None, unsafe="%%&=;+%s" % CUSTOM_INJECTION_MARK_CHAR, convall=False, plusspace=True)
return result
URL decodes given value

    >>> urldecode('AND%201%3E%282%2B3%29%23', convall=True)
    u'AND 1>(2+3)#'
URL decodes given value
URL decodes given value
def urldecode(value, encoding=None, unsafe="%%&=;+%s" % CUSTOM_INJECTION_MARK_CHAR, convall=False, plusspace=True):
    """
    URL decodes given value

    >>> urldecode('AND%201%3E%282%2B3%29%23', convall=True)
    u'AND 1>(2+3)#'
    """

    result = value

    if value:
        try:
            # for cases like T%C3%BCrk%C3%A7e
            value = str(value)
        except ValueError:
            pass
        finally:
            if convall:
                result = urllib.unquote_plus(value) if plusspace else urllib.unquote(value)
            else:
                def _(match):
                    charset = reduce(lambda x, y: x.replace(y, ""), unsafe, string.printable)
                    char = chr(ord(match.group(1).decode("hex")))
                    return char if char in charset else match.group(0)
                result = value
                if plusspace:
                    result = result.replace("+", " ")  # plus sign has a special meaning in URL encoded data (hence the usage of urllib.unquote_plus in convall case)
                result = re.sub("%([0-9a-fA-F]{2})", _, result)

    if isinstance(result, str):
        result = unicode(result, encoding or UNICODE_ENCODING, "replace")

    return result
def urldecode ( value , encoding = None , unsafe = "%%&=;+%s" % CUSTOM_INJECTION_MARK_CHAR , convall = False , plusspace = True ) : result = value if value : try : # for cases like T%C3%BCrk%C3%A7e value = str ( value ) except ValueError : pass finally : if convall : result = urllib . unquote_plus ( value ) if plusspace else urllib . unquote ( value ) else : def _ ( match ) : charset = reduce ( lambda x , y : x . replace ( y , "" ) , unsafe , string . printable ) char = chr ( ord ( match . group ( 1 ) . decode ( "hex" ) ) ) return char if char in charset else match . group ( 0 ) result = value if plusspace : result = result . replace ( "+" , " " ) # plus sign has a special meaning in URL encoded data (hence the usage of urllib.unquote_plus in convall case) result = re . sub ( "%([0-9a-fA-F]{2})" , _ , result ) if isinstance ( result , str ) : result = unicode ( result , encoding or UNICODE_ENCODING , "replace" ) return result