Browse files

[1.0.X] Fixed #10014 -- Don't crash when using debug template tag ins…

…ide a block node tag.

Returning non-ASCII characters from TextNode.__repr__ was causing
problems in the BlockNode.__repr__ method (and probably in other places
we don't know about yet). We now forcibly convert to ascii and replace any
unconvertible characters, rather than returning some moderately
corrupted data in the non-ASCII case.

Backport of r9757 from trunk.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent ad93542 commit 7cef4ecd19b83e6592a1afaedf6aff6fcb7b9e6e @malcolmt malcolmt committed Jan 16, 2009
Showing with 3 additions and 2 deletions.
  1. +3 −2 django/template/
@@ -55,7 +55,7 @@
from django.utils.itercompat import is_iterable
from django.utils.functional import curry, Promise
from django.utils.text import smart_split
-from django.utils.encoding import smart_unicode, force_unicode
+from django.utils.encoding import smart_unicode, force_unicode, smart_str
from django.utils.translation import ugettext as _
from django.utils.safestring import SafeData, EscapeData, mark_safe, mark_for_escaping
from django.utils.html import escape
@@ -785,7 +785,8 @@ def __init__(self, s):
self.s = s
def __repr__(self):
- return "<Text Node: '%s'>" % self.s[:25]
+ return "<Text Node: '%s'>" % smart_str(self.s[:25], 'ascii',
+ errors='replace')
def render(self, context):
return self.s

0 comments on commit 7cef4ec

Please sign in to comment.