|
@@ -54,22 +54,18 @@ from __future__ import unicode_literals
|
|
|
import inspect
|
|
|
import logging
|
|
|
import re
|
|
|
-import warnings
|
|
|
|
|
|
from django.template.context import ( # NOQA: imported for backwards compatibility
|
|
|
BaseContext, Context, ContextPopException, RequestContext,
|
|
|
)
|
|
|
from django.utils import six
|
|
|
-from django.utils.deprecation import RemovedInDjango20Warning
|
|
|
from django.utils.encoding import (
|
|
|
force_str, force_text, python_2_unicode_compatible,
|
|
|
)
|
|
|
from django.utils.formats import localize
|
|
|
from django.utils.html import conditional_escape, escape
|
|
|
from django.utils.inspect import getargspec
|
|
|
-from django.utils.safestring import (
|
|
|
- EscapeData, SafeData, mark_for_escaping, mark_safe,
|
|
|
-)
|
|
|
+from django.utils.safestring import SafeData, mark_safe
|
|
|
from django.utils.text import (
|
|
|
get_text_list, smart_split, unescape_string_literal,
|
|
|
)
|
|
@@ -713,7 +709,6 @@ class FilterExpression(object):
|
|
|
obj = string_if_invalid
|
|
|
else:
|
|
|
obj = self.var
|
|
|
- escape_isnt_last_filter = True
|
|
|
for func, args in self.filters:
|
|
|
arg_vals = []
|
|
|
for lookup, arg in args:
|
|
@@ -729,22 +724,8 @@ class FilterExpression(object):
|
|
|
new_obj = func(obj, *arg_vals)
|
|
|
if getattr(func, 'is_safe', False) and isinstance(obj, SafeData):
|
|
|
obj = mark_safe(new_obj)
|
|
|
- elif isinstance(obj, EscapeData):
|
|
|
- with warnings.catch_warnings():
|
|
|
- # Ignore mark_for_escaping deprecation as this will be
|
|
|
- # removed in Django 2.0.
|
|
|
- warnings.simplefilter('ignore', category=RemovedInDjango20Warning)
|
|
|
- obj = mark_for_escaping(new_obj)
|
|
|
- escape_isnt_last_filter = False
|
|
|
else:
|
|
|
obj = new_obj
|
|
|
- if not escape_isnt_last_filter:
|
|
|
- warnings.warn(
|
|
|
- "escape isn't the last filter in %s and will be applied "
|
|
|
- "immediately in Django 2.0 so the output may change."
|
|
|
- % [func.__name__ for func, _ in self.filters],
|
|
|
- RemovedInDjango20Warning, stacklevel=2
|
|
|
- )
|
|
|
return obj
|
|
|
|
|
|
def args_check(name, func, provided):
|
|
@@ -1015,7 +996,7 @@ def render_value_in_context(value, context):
|
|
|
value = template_localtime(value, use_tz=context.use_tz)
|
|
|
value = localize(value, use_l10n=context.use_l10n)
|
|
|
value = force_text(value)
|
|
|
- if context.autoescape or isinstance(value, EscapeData):
|
|
|
+ if context.autoescape:
|
|
|
return conditional_escape(value)
|
|
|
else:
|
|
|
return value
|