Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #15683 -- Prevented escaped string to be needlessly marked safe…

… twice in force_escape filter. Thanks tyrion for the initial patch.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 8dd04fd84b4f69c4326e120c301d49a6c00e8e64 1 parent 8663bc1
@claudep claudep authored
2  django/template/
@@ -419,7 +419,7 @@ def force_escape(value):
characters (as opposed to "escape", which marks the content for later
possible escaping).
- return mark_safe(escape(value))
+ return escape(value)
@register.filter("linebreaks", is_safe=True, needs_autoescape=True)
6 tests/regressiontests/defaultfilters/
@@ -6,6 +6,7 @@
from django.template.defaultfilters import *
from django.test import TestCase
from django.utils import unittest, translation
+from django.utils.safestring import SafeData
class DefaultFiltersTests(TestCase):
@@ -328,9 +329,10 @@ def test_cut(self):
u'a string to be mangled')
def test_force_escape(self):
+ escaped = force_escape(u'<some html & special characters > here')
- force_escape(u'<some html & special characters > here'),
- u'&lt;some html &amp; special characters &gt; here')
+ escaped, u'&lt;some html &amp; special characters &gt; here')
+ self.assertTrue(isinstance(escaped, SafeData))
force_escape(u'<some html & special characters > here ĐÅ€£'),
u'&lt;some html &amp; special characters &gt; here'\
Please sign in to comment.
Something went wrong with that request. Please try again.