diff options
| author | Baptiste Mispelon <bmispelon@gmail.com> | 2013-06-25 20:28:35 +0200 |
|---|---|---|
| committer | Baptiste Mispelon <bmispelon@gmail.com> | 2013-06-25 20:28:35 +0200 |
| commit | ec371ace004203100d24a74edafc16534dd5d5a9 (patch) | |
| tree | f829d64fea7096f8648e682d9ab9b68b1e4ab67f /django | |
| parent | b91787910c9d5a036674d46a73d1b48ca33123a3 (diff) | |
Fixed #20650 -- Fixed {% filter %} incorrectly accepting 'escape' as argument
Thanks to grzesiof for the report and to loic84 and Alex Gaynor
for the review.
Diffstat (limited to 'django')
| -rw-r--r-- | django/template/base.py | 1 | ||||
| -rw-r--r-- | django/template/defaulttags.py | 5 |
2 files changed, 4 insertions, 2 deletions
diff --git a/django/template/base.py b/django/template/base.py index dc6b0c366c..364b428070 100644 --- a/django/template/base.py +++ b/django/template/base.py @@ -1101,6 +1101,7 @@ class Library(object): # for decorators that need it e.g. stringfilter if hasattr(filter_func, "_decorated_function"): setattr(filter_func._decorated_function, attr, value) + filter_func._filter_name = name return filter_func else: raise InvalidTemplateLibrary("Unsupported arguments to " diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py index 04e7a37d8e..959de3dea1 100644 --- a/django/template/defaulttags.py +++ b/django/template/defaulttags.py @@ -665,8 +665,9 @@ def do_filter(parser, token): _, rest = token.contents.split(None, 1) filter_expr = parser.compile_filter("var|%s" % (rest)) for func, unused in filter_expr.filters: - if getattr(func, '_decorated_function', func).__name__ in ('escape', 'safe'): - raise TemplateSyntaxError('"filter %s" is not permitted. Use the "autoescape" tag instead.' % func.__name__) + filter_name = getattr(func, '_filter_name', None) + if filter_name in ('escape', 'safe'): + raise TemplateSyntaxError('"filter %s" is not permitted. Use the "autoescape" tag instead.' % filter_name) nodelist = parser.parse(('endfilter',)) parser.delete_first_token() return FilterNode(filter_expr, nodelist) |
