diff options
Diffstat (limited to 'mako')
-rw-r--r-- | mako/filters.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/mako/filters.py b/mako/filters.py index 428c926..b1ce924 100644 --- a/mako/filters.py +++ b/mako/filters.py @@ -24,12 +24,15 @@ xml_escapes = { # 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): +def legacy_html_escape(s): """legacy HTML escape for non-unicode mode.""" - - return LEGACY_HTML_ESCAPE_RE.sub(lambda m: xml_escapes[m.group()], string) + s = s.replace("&", "&") + s = s.replace(">", ">") + s = s.replace("<", "<") + s = s.replace('"', """) + s = s.replace("'", "'") + return s + try: import markupsafe |