diff --git a/CHANGES b/CHANGES index 46465f1..970a91b 100644 --- a/CHANGES +++ b/CHANGES @@ -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] diff --git a/mako/filters.py b/mako/filters.py index 37c8fe4..b4f2684 100644 --- a/mako/filters.py +++ b/mako/filters.py @@ -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