#29602: Jinja2's forceescape filter doesn't work on Django's safe strings
---------------------------------+--------------------------------------
     Reporter:  Richard Eames    |                    Owner:  nobody
         Type:  Bug              |                   Status:  new
    Component:  Template system  |                  Version:  2.0
     Severity:  Normal           |               Resolution:
     Keywords:                   |             Triage Stage:  Unreviewed
    Has patch:  0                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+--------------------------------------
Changes (by Tim Graham):

 * cc: Claude Paroz (added)


Comment:

 
[https://github.com/pallets/jinja/blob/3bb2ef8b83cd04bcd77361a4d6a86b3bf4f89529/jinja2/filters.py#L87-L91
 jinja.filters.do_forceescape()] uses
 
[https://github.com/pallets/markupsafe/blob/master/markupsafe/_native.py#L15-L34
 markupsafe.escape()]. Since `str(SafeText)` now returns the `SafeText`,
 the `hasattr(s, '__html__')` check in `escape()` returns True and no
 escaping happens.

 I think it's a legitimate issue as the behavior is certainly unexpected
 (`SafeText` with the Django template language's `force_escape` filter
 works as you would expect), however, I'm not sure what the best way
 forward is as it's a bit late in the Django 2.0 lifecycle to revert the
 original change.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29602#comment:1>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.c9201f771e8cbb6d06bba21264b4e7d9%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to