diff --git a/gluon/utils.py b/gluon/utils.py index 22e3cef4..79fd8604 100644 --- a/gluon/utils.py +++ b/gluon/utils.py @@ -371,16 +371,17 @@ def local_html_escape(data, quote=False): """ if PY2: import cgi - s = cgi.escape(data, quote) - return s.replace("'", "'") if quote else s + data = cgi.escape(data, quote) + return data.replace("'", "'") if quote else data else: import html - if isinstance(s, str): - return html.escape(s, quote=quote) - s = s.replace(b"&", b"&") # Must be done first! - s = s.replace(b"<", b"<") - s = s.replace(b">", b">") + if isinstance(data, str): + return html.escape(data, quote=quote) + data = data.replace(b"&", b"&") # Must be done first! + data = data.replace(b"<", b"<") + data = data.replace(b">", b">") if quote: - s = s.replace(b'"', b""") - s = s.replace(b'\'', b"'") - return s + data = data.replace(b'"', b""") + data = data.replace(b'\'', b"'") + return data +