From: Erik Johnson Date: Tue, 20 Mar 2018 02:56:54 +0000 (-0500) Subject: Remove unescape method for fixing concatenation issue X-Git-Tag: 2.11.0~122^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F826%2Fhead;p=thirdparty%2Fjinja.git Remove unescape method for fixing concatenation issue This ensures that we only concatenate Markup instances to other Markup instances. --- diff --git a/jinja2/filters.py b/jinja2/filters.py index 05a9902d..6d3e463f 100644 --- a/jinja2/filters.py +++ b/jinja2/filters.py @@ -554,31 +554,25 @@ def do_indent( ), stacklevel=2) first = indentfirst - s += u'\n' # this quirk is necessary for splitlines method indention = u' ' * width + newline = u'\n' - def _unescape(val): - ''' - Unescape any strings that were escaped due to concatenation. If the - value passed is not a Markup instance, return the original value. - ''' - try: - return Markup(val.unescape()) - except AttributeError: - # s was not a Markup instance - return val + if isinstance(s, Markup): + indention = Markup(indention) + newline = Markup(newline) + + s += newline # this quirk is necessary for splitlines method if blank: - rv = _unescape((u'\n' + indention).join(s.splitlines())) + rv = (newline + indention).join(s.splitlines()) else: lines = s.splitlines() rv = lines.pop(0) if lines: - rv += u'\n' + u'\n'.join( + rv += newline + newline.join( indention + line if line else line for line in lines ) - rv = _unescape(rv) if first: rv = indention + rv