#29791: Engine.render_to_string() should honor the autoescape attribute
-------------------------------------+-------------------------------------
     Reporter:  Claude Paroz         |                    Owner:  Nathan
                                     |  Gaberel
         Type:  Bug                  |                   Status:  closed
    Component:  Template system      |                  Version:  dev
     Severity:  Normal               |               Resolution:  fixed
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Malik A. Rumi):

 I came here because I cannot get autoescape to turn off. First I put it in
 my template, surrounding the links I wanted to work, but it did not. I
 looked around and saw that I could control it the same way template
 inheritance works, so I went to my base html template and put the
 autoescape tags there. It still had no effect. Then I rebooted, hoping
 that would make a difference. It did not.

 I do not understand how this patch works. Given that at line 20 of
 engine.py, the __init__ has


 {{{
 autoescape = True,
 }}}
 what are
 {{{
 self.autoescape=autoescape [line 44]
 }}}
 and
 {{{
 autoescape=self.autoescape [line 163]
 }}}
 actually doing? It just looks like a circular assignment to me.

 Further, I don’t see how this is connected to template tags. I see no
 reference to tags in any of this code. Perhaps it is somewhere else, and
 happens magically, but regardless, I don’t see it.

 Finally, I do not understand the test you ran.


 {{{
 self.assertEqual(
             engine.render_to_string('test_context.html', {'obj':
 '<script>'}),
             'obj:<script>\n',
         )
 }}}


 It looks to me like all you are doing here is removing the curly braces
 from a dict, and adding a newline. What has that got to do with
 autoescaping html? The angle brackets in your test object are still there.

 In my templates, all that html is removed in favor of html entities - as
 you can see from the screen shots I attached.. That means the links don't
 work, don’t display, and give me repeated NoReverseMatch errors even when
 the code Django tried was correct.

 I would ask that you re-open this ticket and make the autoescape tag work
 as advertised.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29791#comment:7>
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.1fca75988138d0fd2f413245d758ef5c%40djangoproject.com.

Reply via email to