Skip to content
Snippets Groups Projects
Commit 2f40aa94 authored by Mike Bayer's avatar Mike Bayer
Browse files

- Added a try/except around "import markupsafe".

  This to support GAE which can't run markupsafe.
  [ticket:151] No idea whatsoever if the
  install_requires in setup.py also breaks GAE,
  couldn't get an answer on this.
parent 8bb8f0b5
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,12 @@
inside of a tag element that doesn't allow
them raises a CompileException instead of
silently failing.
- Added a try/except around "import markupsafe".
This to support GAE which can't run markupsafe.
[ticket:151] No idea whatsoever if the
install_requires in setup.py also breaks GAE,
couldn't get an answer on this.
0.3.4
- Now using MarkupSafe for HTML escaping,
......
......@@ -8,7 +8,6 @@
import re, urllib, htmlentitydefs, codecs
from StringIO import StringIO
from mako import util
import markupsafe
xml_escapes = {
'&' : '&',
......@@ -21,13 +20,18 @@ xml_escapes = {
# XXX: " is valid in HTML and XML
# ' is not valid HTML, but is valid XML
def html_escape(string):
return markupsafe.escape(string)
def legacy_html_escape(string):
"""legacy HTML escape for non-unicode mode."""
return re.sub(r'([&<"\'>])', lambda m: xml_escapes[m.group()], string)
try:
import markupsafe
def html_escape(string):
return markupsafe.escape(string)
except ImportError:
html_escape = legacy_html_escape
def xml_escape(string):
return re.sub(r'([&<"\'>])', lambda m: xml_escapes[m.group()], string)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment