From: Erik Johnson Date: Mon, 19 Mar 2018 21:03:00 +0000 (-0500) Subject: Apply unesacpe fix when blank is True X-Git-Tag: 2.11.0~122^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5db859c5c3f43d403eaaff3e65b0aa8b2bdc5d13;p=thirdparty%2Fjinja.git Apply unesacpe fix when blank is True --- diff --git a/jinja2/filters.py b/jinja2/filters.py index ab02ca3c..05a9902d 100644 --- a/jinja2/filters.py +++ b/jinja2/filters.py @@ -557,8 +557,19 @@ def do_indent( s += u'\n' # this quirk is necessary for splitlines method indention = u' ' * width + 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 blank: - rv = (u'\n' + indention).join(s.splitlines()) + rv = _unescape((u'\n' + indention).join(s.splitlines())) else: lines = s.splitlines() rv = lines.pop(0) @@ -567,12 +578,7 @@ def do_indent( rv += u'\n' + u'\n'.join( indention + line if line else line for line in lines ) - try: - # Unescape any strings that were escaped due to concatenation - rv = Markup(rv.unescape()) - except AttributeError: - # s was not a Markup instance - pass + rv = _unescape(rv) if first: rv = indention + rv