Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #5983 -- Made iriencode filter respect safe strings. Patch from

SmileyChris.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@6706 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 2e9e36e29744ca638ca34799d79a6eb638a2d822 1 parent ab69710
Malcolm Tredinnick authored November 20, 2007
1  django/template/defaultfilters.py
@@ -106,6 +106,7 @@ def floatformat(text, arg=-1):
106 106
 def iriencode(value):
107 107
     """Escapes an IRI value for use in a URL."""
108 108
     return force_unicode(iri_to_uri(value))
  109
+iriencode.is_safe = True
109 110
 iriencode = stringfilter(iriencode)
110 111
 
111 112
 def linenumbers(value, autoescape=None):
6  tests/regressiontests/templates/filters.py
@@ -198,6 +198,12 @@ def get_filter_tests():
198 198
         '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>"),
199 199
         '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>"),
200 200
 
  201
+        # Ensure iriencode keeps safe strings:
  202
+        'filter-iriencode01': ('{{ url|iriencode }}', {'url': '?test=1&me=2'}, '?test=1&amp;me=2'),
  203
+        'filter-iriencode02': ('{% autoescape off %}{{ url|iriencode }}{% endautoescape %}', {'url': '?test=1&me=2'}, '?test=1&me=2'),
  204
+        'filter-iriencode03': ('{{ url|iriencode }}', {'url': mark_safe('?test=1&me=2')}, '?test=1&me=2'),
  205
+        'filter-iriencode04': ('{% autoescape off %}{{ url|iriencode }}{% endautoescape %}', {'url': mark_safe('?test=1&me=2')}, '?test=1&me=2'),
  206
+
201 207
         # Chaining a bunch of safeness-preserving filters should not alter
202 208
         # the safe status either way.
203 209
         'chaining01': ('{{ a|capfirst|center:"7" }}.{{ b|capfirst|center:"7" }}', {"a": "a < b", "b": mark_safe("a < b")}, " A &lt; b . A < b "),

0 notes on commit 2e9e36e

Please sign in to comment.
Something went wrong with that request. Please try again.