Skip to content

Instantly share code, notes, and snippets.

@eligrey
Forked from jed/LICENSE.txt
Last active April 24, 2018 00:32
Show Gist options
  • Save eligrey/1224209 to your computer and use it in GitHub Desktop.
Save eligrey/1224209 to your computer and use it in GitHub Desktop.
use cached DOM elements to escape HTML
new Option(c).innerHTML
new Option(c).innerHTML

Public domain. NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.

{
"name": "escapeHTML",
"keywords": ["escape", "escaping", "HTML", "XSS"]
}
@jed
Copy link

jed commented Sep 17, 2011

what exactly does this closure get you?

@eligrey
Copy link
Author

eligrey commented Sep 17, 2011

Nothing. I'm just following the 140byt.es rules.

@jed
Copy link

jed commented Sep 17, 2011

heh, which rule is that exactly? this would do, no?

function(a){return new Option(a).innerHTML}

@eligrey
Copy link
Author

eligrey commented Sep 17, 2011

Oh it seems you're right, now that I've actually read the rules. I'll fork the 140byt.es thing and make a new submission.

@jed
Copy link

jed commented Sep 17, 2011

no need, i'll edit mine!

@jed
Copy link

jed commented Sep 17, 2011 via email

@jdalton
Copy link

jdalton commented Sep 19, 2011

This won't work in IE < 9

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