2 ms·
I'm very skeptical about the value of stripping HTML from user input - what if your site is a forum where people discuss HTML? Or a site where people might want
by simonw 18y ago
I'm very skeptical about the value of stripping HTML from user input - what if your site is a forum where people discuss HTML? Or a site where people might want to talk about the <head> conference? http://www.headconference.com/ http://www.headconference.com/
Stripping HTML on input also means you lose the ability to audit attempted attacks against your site.
A much smarter strategy in my opinion is to escape everything on output. That way it doesn't matter what people submit to your site - unless you explicitly say "this is safe to display unescaped" in your templates harmful characters will be neutralised.
- mtw 18y agowhite_list is a better option, imho
- 100k 18y agoYup. I am suggesting escaping HTML on output (of user input) by default -- making h() the default, essentially. (Incidentally, the reason why this will probably never happen is that it would break all of Rails' HTML helpers.) There are several frameworks that do this already. Django even broke existing apps to make such a change.