summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-11-30 15:32:01 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-11-30 15:32:01 +0000
commit8de4ed9c8cae403bc59588cac9a258e5573b4842 (patch)
tree12e70ac77cce0c07f19922479df6be6add0a3018
parent275cffaab162d49db5cad52abb9b67473378be07 (diff)
Fixed #6057 -- Mark rendered template output as safe for auto-escaping purposes.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6778 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/template/__init__.py2
-rw-r--r--tests/regressiontests/templates/unicode.py10
2 files changed, 8 insertions, 4 deletions
diff --git a/django/template/__init__.py b/django/template/__init__.py
index c68a4b544d..9b1868cfce 100644
--- a/django/template/__init__.py
+++ b/django/template/__init__.py
@@ -804,7 +804,7 @@ class NodeList(list):
bits.append(self.render_node(node, context))
else:
bits.append(node)
- return ''.join([force_unicode(b) for b in bits])
+ return mark_safe(''.join([force_unicode(b) for b in bits]))
def get_nodes_by_type(self, nodetype):
"Return a list of all nodes of the given type"
diff --git a/tests/regressiontests/templates/unicode.py b/tests/regressiontests/templates/unicode.py
index efda11c2da..e5f308d202 100644
--- a/tests/regressiontests/templates/unicode.py
+++ b/tests/regressiontests/templates/unicode.py
@@ -3,6 +3,7 @@
unicode_tests = ur"""
Templates can be created from unicode strings.
>>> from django.template import *
+>>> from django.utils.safestring import SafeData
>>> t1 = Template(u'ŠĐĆŽćžšđ {{ var }}')
Templates can also be created from bytestrings. These are assumed by encoded
@@ -24,10 +25,13 @@ Contexts can be constructed from unicode or UTF-8 bytestrings.
>>> c4 = Context({u'var': '\xc4\x90\xc4\x91'})
Since both templates and all four contexts represent the same thing, they all
-render the same (and are returned as unicode objects).
+render the same (and are returned as unicode objects and "safe" objects as
+well, for auto-escaping purposes).
>>> t1.render(c3) == t2.render(c3)
True
->>> type(t1.render(c3))
-<type 'unicode'>
+>>> isinstance(t1.render(c3), unicode)
+True
+>>> isinstance(t1.render(c3), SafeData)
+True
"""