How do I filter out Dangerous HTML like SO does? [duplicate]
问题 This question already has answers here : How to prevent XSS with HTML/PHP? (10 answers) Sanitizing HTML input (4 answers) Closed 6 years ago . I want to provide an HTML editor on my site, but don't want to open myself up to xss or other attacks that come with allowing user-generated HTML. This is pretty similar to what Stack Overflow does. How is the HTML checked/sanitized here so that the styling information still remains, while other, more dangerous stuff (like javascript, iframes, etc.)