#24469: forms, form fields and media are escaped wrongfully in non django 
templates
-------------------------------------+-------------------------------------
     Reporter:  MoritzS              |                    Owner:  aaugustin
         Type:  Bug                  |                   Status:  assigned
    Component:  Template system      |                  Version:  1.8beta2
     Severity:  Normal               |               Resolution:
     Keywords:  forms fields media   |             Triage Stage:
  escape template jinja2             |  Unreviewed
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by MoritzS):

 I looked into django's and jinja2's template code and found out what the
 problem is:

 The django template engine calls
 `django.template.base.render_value_in_context` for each variable. There
 the object gets converted to a string with `force_text`. That just calls
 `__str__` or `__unicode__` of the object and correctly gets a `SafeText`.

 jinja2 however doesn't use `force_text` or `str()`, it uses `escape` from
 the markupsafe library.
 Markupsafe then sees that the form, field or media doesn't have a
 `__html__` method so it decides to mark it unsafe and escape the html
 characters.

--
Ticket URL: <https://code.djangoproject.com/ticket/24469#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.201314dfeee47770f53bfe1610285ff4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to