summaryrefslogtreecommitdiff
path: root/mako
diff options
context:
space:
mode:
Diffstat (limited to 'mako')
-rw-r--r--mako/filters.py13
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("&", "&amp;")
+ s = s.replace(">", "&gt;")
+ s = s.replace("<", "&lt;")
+ s = s.replace('"', "&#34;")
+ s = s.replace("'", "&#39;")
+ return s
+
try:
import markupsafe