Author: mtredinnick
Date: 2007-11-19 19:37:57 -0600 (Mon, 19 Nov 2007)
New Revision: 6706
Modified:
django/trunk/django/template/defaultfilters.py
django/trunk/tests/regressiontests/templates/filters.py
Log:
Fixed #5983 -- Made iriencode filter respect safe strings. Patch from
SmileyChris.
Modified: django/trunk/django/template/defaultfilters.py
===================================================================
--- django/trunk/django/template/defaultfilters.py 2007-11-20 01:37:34 UTC
(rev 6705)
+++ django/trunk/django/template/defaultfilters.py 2007-11-20 01:37:57 UTC
(rev 6706)
@@ -106,6 +106,7 @@
def iriencode(value):
"""Escapes an IRI value for use in a URL."""
return force_unicode(iri_to_uri(value))
+iriencode.is_safe = True
iriencode = stringfilter(iriencode)
def linenumbers(value, autoescape=None):
Modified: django/trunk/tests/regressiontests/templates/filters.py
===================================================================
--- django/trunk/tests/regressiontests/templates/filters.py 2007-11-20
01:37:34 UTC (rev 6705)
+++ django/trunk/tests/regressiontests/templates/filters.py 2007-11-20
01:37:57 UTC (rev 6706)
@@ -198,6 +198,12 @@
'filter-phone2numeric01': ('{{ a|phone2numeric }} {{ b|phone2numeric
}}', {"a": "<1-800-call-me>", "b": mark_safe("<1-800-call-me>") },
"<1-800-2255-63> <1-800-2255-63>"),
'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>"),
+ # Ensure iriencode keeps safe strings:
+ 'filter-iriencode01': ('{{ url|iriencode }}', {'url': '?test=1&me=2'},
'?test=1&me=2'),
+ 'filter-iriencode02': ('{% autoescape off %}{{ url|iriencode }}{%
endautoescape %}', {'url': '?test=1&me=2'}, '?test=1&me=2'),
+ 'filter-iriencode03': ('{{ url|iriencode }}', {'url':
mark_safe('?test=1&me=2')}, '?test=1&me=2'),
+ 'filter-iriencode04': ('{% autoescape off %}{{ url|iriencode }}{%
endautoescape %}', {'url': mark_safe('?test=1&me=2')}, '?test=1&me=2'),
+
# Chaining a bunch of safeness-preserving filters should not alter
# the safe status either way.
'chaining01': ('{{ a|capfirst|center:"7" }}.{{ b|capfirst|center:"7"
}}', {"a": "a < b", "b": mark_safe("a < b")}, " A < b . A < b "),
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---