Skip to content

Commit

Permalink
- [bug] legacy_html_escape function, used when
Browse files Browse the repository at this point in the history
  Markupsafe isn't installed, was using an inline-compiled
  regexp which causes major slowdowns on Python 3.3;
  is now precompiled.
  • Loading branch information
zzzeek committed Nov 2, 2012
1 parent 7286cb0 commit b47783a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@

0.7.3
- [bug] legacy_html_escape function, used when
Markupsafe isn't installed, was using an inline-compiled
regexp which causes major slowdowns on Python 3.3;
is now precompiled.

- [bug] AST supporting now supports tuple-packed
function arguments inside pure-python def
or lambda expressions. [ticket:201]
Expand Down
4 changes: 3 additions & 1 deletion mako/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
# XXX: " is valid in HTML and XML
# ' is not valid HTML, but is valid XML

LEGACY_HTML_ESCAPE_RE = re.compile(r'([&<"\'>])')

def legacy_html_escape(string):
"""legacy HTML escape for non-unicode mode."""

return re.sub(r'([&<"\'>])', lambda m: xml_escapes[m.group()], string)
return LEGACY_HTML_ESCAPE_RE.sub(lambda m: xml_escapes[m.group()], string)

try:
import markupsafe
Expand Down

0 comments on commit b47783a

Please sign in to comment.