Ticket #5734: utils_http_urlquote_safe.diff

File utils_http_urlquote_safe.diff, 1.2 KB (added by Thomas Güttler <hv@…>, 17 years ago)
  • django/utils/http.py

     
    99    can safely be used as part of an argument to a subsequent iri_to_uri() call
    1010    without double-quoting occurring.
    1111    """
    12     return force_unicode(urllib.quote(smart_str(url)))
     12    return force_unicode(urllib.quote(smart_str(url), safe))
     13
    1314urlquote = allow_lazy(urlquote, unicode)
    1415
    1516def urlquote_plus(url, safe=''):
  • tests/regressiontests/text/tests.py

     
    2020>>> from django.utils.http import urlquote, urlquote_plus
    2121>>> urlquote(u'Paris & Orl\xe9ans')
    2222u'Paris%20%26%20Orl%C3%A9ans'
     23>>> urlquote(u'Paris & Orl\xe9ans', safe="&")
     24u'Paris%20&%20Orl%C3%A9ans'
    2325>>> urlquote_plus(u'Paris & Orl\xe9ans')
    2426u'Paris+%26+Orl%C3%A9ans'
     27>>> urlquote_plus(u'Paris & Orl\xe9ans', safe="&")
     28u'Paris+&+Orl%C3%A9ans'
    2529
    2630### iri_to_uri ###########################################################
    2731>>> from django.utils.encoding import iri_to_uri
Back to Top