Why is appending to the innerHTML property bad?
stackoverflow.com4 pointsby lucgommans2 comments
$ python -m this | grep -- -- -
Which is just beautiful Fun facts:
* Night Driver (W) said "1 Shazams". I think I was the first person to ever Shazam that. Some of the most obscure things had hundreds, often thousands of shazams!
* You know where they are taking the hobbits but none of the services do!
========
- ABC = found the song
- # = number of attempts
- f = exceptionally fast matching (when it did match, might not be first attempt)
- ~ = knew one of the songs
BeatFind: 2B C 1E 2G 2H 1I 2Jf 2Lf 4M 2Nf 2Of 1Pf 1Rf ~S 2T 1Uf 1Vf 1W 1Xf Y Z
SoundHound: A 1B 1E 2F 1G 2H 2If 1L 2O 3P 2R 1Tf 2U
Shazam: 1Bf 1D 1E 1F 1G 1Hf 1I 2J 1L 1M 4N 1O 1Pf 1Rf 1Tf 1Uf 1V 2W 1X Y Z
MusixMatch: crashes on startup, presumably it realizes it won't be able to show me ads
missingno
Shazam: A C K Q S
SoundHound: C D F J K M/N Q S V W X Y Z
BeatFind: A D F K Q
non-universal finds (repeated letter = unique = counts double; slash means same artist so should be counted as one)
Shazam: DD F J M/N V X Y Z
SoundHound: AA F
BeatFind: CC J M/N S V X Y Z
A: Levan Polkka Epic Orchestral Cover version
B: Pokémon red/blue soundtrack
C: Mayhem (various songs, it seems either they have all or they have none)
D: Art Now ft. Snowflake
E: Hero's Choice
F: Three Days Grace - Scared
G: Syrian - Supernova
H: The Explosion - Here I Am
I: The Von Bondies - C'mon C'mon
J: Frank Klepacki - Scouting (C&C TibSun)
K: Conspiracy - Chaos Theory (demoscene)
L: Cheshyre - Madness6 (remix) (Newgrounds ID 77998)
M: Dimrain47 - Twilight Techno
N: Dimrain47 - Cloud Control
O: DragonForce - My Spirit Will Go On
P: Yuki Kajiura - The First Town (SAO)
Q: THEY'RE TAKING THE HOBBITS TO ISENGARD! THE HOBBITS- THE HOBBITS- TO ISENGARD! TO ISENGARD!
R: Faithless - Insomnia
S: Age of Empires 1 soundtrack
T: Moulin Rouge - El Tango De Roxanne
U: Van Canto - Master of Puppets
V: Slack Bird - Jouni
W: Floppytronic - Night Driver
X: EgoSalad / Kitboga - Breathe in
Y: Floppy Drive music: top 4 hits on yt: sweet dreams, imperial march, ghostbusters, beat it. Only ghostbusters was known to any
Z: Obsidian Shell - Orphanage
---
Sanitisation is one of two possible defences, the other being script execution controls or sandboxing. E.g., if you serve vector images on a web server, set a Content Security Policy header¹ for all your images that simply denies all scripting. You can also run it from a dummy domain ('origin') with nothing valuable on it (like how domains such as googleusercontent.com and githubusercontent.com are being used)
For sanitisation, DOMPurify² is the only widely used and tested library that I know of. It could use more bindings for other languages but, if you can call into it, it can go in your deployment pipeline. (Disclosure: I've worked with some of the people at Cure53, but not on this project)
You can also combine the approaches for defence in depth
¹ https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CSP
² https://github.com/cure53/DOMPurify