Skip to content
Myr

Remove unescape method for fixing concatenation issue

Before adoption: this commit came in with the history the project adopted, so no landing records it.

This ensures that we only concatenate Markup instances to other Markup instances.

authored by Erik Johnson · committed by Erik Johnson · parent 8ef99c3 · Browse files · 1 file+8 added−14 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+8 added−14 removed

  • other:+8 added−14 removed

1 file+8 added−14 removed

modified:jinja2/filters.py+8 added-14 removed
552 unmodified lines
553 'The "indentfirst" argument is renamed to "first".'554 ), stacklevel=2)555 first = indentfirst556557 s += u'\n' # this quirk is necessary for splitlines method557 indention = u' ' * width558 newline = u'\n'559560 def _unescape(val):561 '''562 Unescape any strings that were escaped due to concatenation. If the563 value passed is not a Markup instance, return the original value.564 '''565 try:566 return Markup(val.unescape())567 except AttributeError:568 # s was not a Markup instance569 return val560 if isinstance(s, Markup):561 indention = Markup(indention)562 newline = Markup(newline)563564 s += newline # this quirk is necessary for splitlines method565566 if blank:572 rv = _unescape((u'\n' + indention).join(s.splitlines()))567 rv = (newline + indention).join(s.splitlines())568 else:569 lines = s.splitlines()570 rv = lines.pop(0)571572 if lines:578 rv += u'\n' + u'\n'.join(573 rv += newline + newline.join(574 indention + line if line else line for line in lines575 )581 rv = _unescape(rv)576577 if first:578 rv = indention + rv579
617 unmodified lines