Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 3
    Just a note that this won't solve the case where you might want to use user input as an HTML attribute. For example, the source URL of an image. Not a common case, but an easy one to forget. Commented May 16, 2011 at 17:12
  • @MichaelMior here is a solution to prevent XSS in href or src HTML attribute: stackoverflow.com/questions/19047119/… Commented Jul 20, 2019 at 11:30
  • There's a nice article here that explains XSS and how to prevent it in different languages (incl. PHP). Commented Apr 14, 2020 at 20:12
  • Check my package if you want to allow HTML and keep it safe github.com/medilies/xssless Commented Aug 10, 2024 at 18:31