fixed last_sql_parse for py3

This commit is contained in:
mdipierro
2016-08-01 05:23:40 -05:00
parent 7440d38253
commit be5ddca28f
+11 -10
View File
@@ -371,16 +371,17 @@ def local_html_escape(data, quote=False):
""" """
if PY2: if PY2:
import cgi import cgi
s = cgi.escape(data, quote) data = cgi.escape(data, quote)
return s.replace("'", "'") if quote else s return data.replace("'", "'") if quote else data
else: else:
import html import html
if isinstance(s, str): if isinstance(data, str):
return html.escape(s, quote=quote) return html.escape(data, quote=quote)
s = s.replace(b"&", b"&") # Must be done first! data = data.replace(b"&", b"&") # Must be done first!
s = s.replace(b"<", b"&lt;") data = data.replace(b"<", b"&lt;")
s = s.replace(b">", b"&gt;") data = data.replace(b">", b"&gt;")
if quote: if quote:
s = s.replace(b'"', b"&quot;") data = data.replace(b'"', b"&quot;")
s = s.replace(b'\'', b"&#x27;") data = data.replace(b'\'', b"&#x27;")
return s return data