3 ms·
> > default to HTML escaping on output > ??? Is that a joke? Don't do that! That's just as bad as magic quotes. No, it's not. Magic quotes are a pain to rever
by skrebbel 14y ago
> > default to HTML escaping on output
> ??? Is that a joke? Don't do that! That's just as bad as magic quotes.
No, it's not. Magic quotes are a pain to reverse. HTML escaping can be built into the echo/print/<?= .. ?> commands, so that it is:
- A setting that can be totally turned off at run-time, if you want;
- Easily overridden on a case-by-case basis with a 'rawecho' function that
does *not* escape anything.
- ars 14y agoI've seen too many multiply encoded things to be so sure this is a good idea. Plus too many cases of extra backslashes from back in the magic quotes days.
- pwmanagerdied 14y agoI've seen too many sites with XSS vulnerabilities to think it's a bad idea. Negligence should result in mangled output, not a security problem.
- padraicb 14y agoProblem with HTML escaping by default - it's not all HTML escaping. Javascript strings need to be JS escaped, sometimes escaped by HTML as a second (or even first) step to complete the correct encoding needed to avoid XSS for the specific context(s) that output actually ends up in for a browser. Same for CSS, URIs, vbscript, parameters, etc. HTML escaping is not the one and only escaping strategy that magically makes everything safe. So any automated system would need to incorporate overrides on a per variable basis. http://blog.astrumfutura.com/2012/06/automatic-output-escaping-in-php-and-the-real-future-of-preventing-cross-site-scripting-xss/ http://blog.astrumfutura.com/2012/06/automatic-output-escapi...