From 5db859c5c3f43d403eaaff3e65b0aa8b2bdc5d13 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Mon, 19 Mar 2018 16:03:00 -0500 Subject: [PATCH] Apply unesacpe fix when blank is True --- jinja2/filters.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) 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 -- 2.47.3