mirror of https://github.com/django/django.git
Fixed #29791 -- Made Engine.render_to_string() honor autoescape.
This commit is contained in:
parent
d4df5e1b0b
commit
624573726a
1
AUTHORS
1
AUTHORS
|
@ -627,6 +627,7 @@ answer newbie questions, and generally made Django that much better:
|
|||
Nasir Hussain <nasirhjafri@gmail.com>
|
||||
Natalia Bidart <nataliabidart@gmail.com>
|
||||
Nate Bragg <jonathan.bragg@alum.rpi.edu>
|
||||
Nathan Gaberel <nathan@gnab.fr>
|
||||
Neal Norwitz <nnorwitz@google.com>
|
||||
Nebojša Dorđević
|
||||
Ned Batchelder <https://nedbatchelder.com/>
|
||||
|
|
|
@ -160,7 +160,7 @@ class Engine:
|
|||
if isinstance(context, Context):
|
||||
return t.render(context)
|
||||
else:
|
||||
return t.render(Context(context))
|
||||
return t.render(Context(context, autoescape=self.autoescape))
|
||||
|
||||
def select_template(self, template_name_list):
|
||||
"""
|
||||
|
|
|
@ -21,6 +21,13 @@ class RenderToStringTest(SimpleTestCase):
|
|||
'obj:test\n',
|
||||
)
|
||||
|
||||
def test_autoescape_off(self):
|
||||
engine = Engine(dirs=[TEMPLATE_DIR], autoescape=False)
|
||||
self.assertEqual(
|
||||
engine.render_to_string('test_context.html', {'obj': '<script>'}),
|
||||
'obj:<script>\n',
|
||||
)
|
||||
|
||||
|
||||
class GetDefaultTests(SimpleTestCase):
|
||||
|
||||
|
|
Loading…
Reference in New Issue