Ticket #5964: urlunquote.diff

File urlunquote.diff, 1.4 KB (added by Thomas Güttler (Home) < >, 11 years ago)
  • django/utils/http.py

     
    2525    return force_unicode(urllib.quote_plus(smart_str(url), safe))
    2626urlquote_plus = allow_lazy(urlquote_plus, unicode)
    2727
     28def urlunquote(url_quoted):
     29    """
     30    A version of Python's urllib.unquote() function that can operate on
     31    the result of django's urlquote() functions.
     32    """
     33    return unicode(urllib.unquote(str(url_quoted)), 'utf8')
     34urlunquote = allow_lazy(urlunquote, unicode)
     35
    2836def urlencode(query, doseq=0):
    2937    """
    3038    A version of Python's urllib.urlencode() function that can operate on
  • tests/regressiontests/text/tests.py

     
    1717friends'
    1818
    1919### urlquote #############################################################
    20 >>> from django.utils.http import urlquote, urlquote_plus
     20>>> from django.utils.http import urlquote, urlquote_plus, urlunquote
    2121>>> urlquote(u'Paris & Orl\xe9ans')
    2222u'Paris%20%26%20Orl%C3%A9ans'
     23>>> urlunquote(urlquote(u'Paris & Orl\xe9ans'))==u'Paris & Orl\xe9ans'
     24True
    2325>>> urlquote(u'Paris & Orl\xe9ans', safe="&")
    2426u'Paris%20&%20Orl%C3%A9ans'
    2527>>> urlquote_plus(u'Paris & Orl\xe9ans')
Back to Top