Skip to content

Instantly share code, notes, and snippets.

@kgleeson
Created September 11, 2012 10:40
Show Gist options
  • Save kgleeson/3697524 to your computer and use it in GitHub Desktop.
Save kgleeson/3697524 to your computer and use it in GitHub Desktop.
def escape_html(s):
list = [('&', '&'),
('<', '&lt;'),
('"', '&quot;'),
('>', '&gt;')]
for i in list:
if i[0] in s:
s = s.replace(i[0],i[1])
return s
@zeffii
Copy link

zeffii commented Sep 11, 2012

def escape_html(s): for i in ('&', '&amp;'), ('<', '&lt;'), ('"', '&quot;'), ('>', '&gt;') : if i[0] in s: s = s.replace(i[0],i[1]) return s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment