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
  • Select an option

  • Save eligrey/1224209 to your computer and use it in GitHub Desktop.

Select an option

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

jed commented Sep 17, 2011

Copy link
Copy Markdown

what exactly does this closure get you?

@eligrey

eligrey commented Sep 17, 2011

Copy link
Copy Markdown
Author

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

@jed

jed commented Sep 17, 2011

Copy link
Copy Markdown

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

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

@eligrey

eligrey commented Sep 17, 2011

Copy link
Copy Markdown
Author

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

jed commented Sep 17, 2011

Copy link
Copy Markdown

no need, i'll edit mine!

@jed

jed commented Sep 17, 2011 via email

Copy link
Copy Markdown

@jdalton

jdalton commented Sep 19, 2011

Copy link
Copy Markdown

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