Ticket #5983: safe_iriencode.diff

File safe_iriencode.diff, 1.6 KB (added by Chris Beaven, 17 years ago)
  • tests/regressiontests/templates/filters.py

     
    194194        'filter-phone2numeric01': ('{{ a|phone2numeric }} {{ b|phone2numeric }}', {"a": "<1-800-call-me>", "b": mark_safe("<1-800-call-me>") }, "&lt;1-800-2255-63&gt; <1-800-2255-63>"),
    195195        'filter-phone2numeric02': ('{% autoescape off %}{{ a|phone2numeric }} {{ b|phone2numeric }}{% endautoescape %}', {"a": "<1-800-call-me>", "b": mark_safe("<1-800-call-me>") }, "<1-800-2255-63> <1-800-2255-63>"),
    196196
     197        # Ensure iriencode keeps safe strings:
     198        'filter-iriencode01': ('{{ url|iriencode }}', {'url': '?test=1&me=2'}, '?test=1&amp;me=2'),
     199        'filter-iriencode02': ('{{ url|iriencode }}', {'url': mark_safe('?test=1&me=2')}, '?test=1&me=2'),
     200
    197201        # Chaining a bunch of safeness-preserving filters should not alter
    198202        # the safe status either way.
    199203        'chaining01': ('{{ a|capfirst|center:"7" }}.{{ b|capfirst|center:"7" }}', {"a": "a < b", "b": mark_safe("a < b")}, " A &lt; b . A < b "),
  • django/template/defaultfilters.py

     
    107107    """Escapes an IRI value for use in a URL."""
    108108    return force_unicode(iri_to_uri(value))
    109109iriencode = stringfilter(iriencode)
     110iriencode.is_safe = True
    110111
    111112def linenumbers(value, autoescape=None):
    112113    """Displays text with line numbers."""
Back to Top