diff options
| author | Luke Plant <L.Plant.98@cantab.net> | 2015-06-15 11:17:09 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-06-29 08:16:19 -0400 |
| commit | aef2a0ec59301022354c043744a6a2fa13583aa1 (patch) | |
| tree | ad562a7c7c5379594b499e14574e181188a51f10 /django | |
| parent | 9ed82154bd0bd01c6195942db84302e791ad366f (diff) | |
Fixed #25018 -- Changed simple_tag to apply conditional_escape() to its output.
This is a security hardening fix to help prevent XSS (and incorrect HTML)
for the common use case of simple_tag.
Thanks to Tim Graham for the review.
Diffstat (limited to 'django')
| -rw-r--r-- | django/template/library.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/django/template/library.py b/django/template/library.py index 1eaaf4c0be..23364e8024 100644 --- a/django/template/library.py +++ b/django/template/library.py @@ -4,6 +4,7 @@ from importlib import import_module from django.utils import six from django.utils.deprecation import RemovedInDjango20Warning +from django.utils.html import conditional_escape from django.utils.inspect import getargspec from django.utils.itercompat import is_iterable @@ -201,6 +202,8 @@ class SimpleNode(TagHelperNode): if self.target_var is not None: context[self.target_var] = output return '' + if context.autoescape: + output = conditional_escape(output) return output |
