Skip to content

Instantly share code, notes, and snippets.

@piyonishi
Created May 7, 2013 09:07
Show Gist options
  • Save piyonishi/5531302 to your computer and use it in GitHub Desktop.
Save piyonishi/5531302 to your computer and use it in GitHub Desktop.
def escape_html(self, var):
meta_chars = {
'"': '"',
'\'': ''',
'&': '&',
'<': '&lt;',
'>': '&gt;',
}
escaped_var = ""
for i in var:
if i in meta_chars:
escaped_var = escaped_var + meta_chars[i]
else:
escaped_var = escaped_var + i
return escaped_var
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment