Django

Code

Changeset 6778

Show
Ignore:
Timestamp:
11/30/07 09:32:01 (1 year ago)
Author:
mtredinnick
Message:

Fixed #6057 -- Mark rendered template output as safe for auto-escaping purposes.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/template/__init__.py

    r6724 r6778  
    805805            else: 
    806806                bits.append(node) 
    807         return ''.join([force_unicode(b) for b in bits]
     807        return mark_safe(''.join([force_unicode(b) for b in bits])
    808808 
    809809    def get_nodes_by_type(self, nodetype): 
  • django/trunk/tests/regressiontests/templates/unicode.py

    r5876 r6778  
    44Templates can be created from unicode strings. 
    55>>> from django.template import * 
     6>>> from django.utils.safestring import SafeData 
    67>>> t1 = Template(u'ŠĐĆŽćžšđ {{ var }}') 
    78 
     
    2526 
    2627Since both templates and all four contexts represent the same thing, they all 
    27 render the same (and are returned as unicode objects). 
     28render the same (and are returned as unicode objects and "safe" objects as 
     29well, for auto-escaping purposes). 
    2830 
    2931>>> t1.render(c3) == t2.render(c3) 
    3032True 
    31 >>> type(t1.render(c3)) 
    32 <type 'unicode'> 
     33>>> isinstance(t1.render(c3), unicode) 
     34True 
     35>>> isinstance(t1.render(c3), SafeData) 
     36True 
    3337"""