]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
Apply unesacpe fix when blank is True
authorErik Johnson <palehose@gmail.com>
Mon, 19 Mar 2018 21:03:00 +0000 (16:03 -0500)
committerErik Johnson <palehose@gmail.com>
Mon, 19 Mar 2018 21:03:00 +0000 (16:03 -0500)
jinja2/filters.py

index ab02ca3cbd0668826675ad34603164841f3f3dd5..05a9902d762bb6d536ba8261da9f1b7daa69d60f 100644 (file)
@@ -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