How can I allow HTML in a whitelist with PHP

后端 未结 4 2144
遇见更好的自我
遇见更好的自我 2020-12-11 12:02

I know there is a lot of discussion for years on best methods of filtering data with PHP but I would like to go the whitelist approach in my current project.

I only

4条回答
  •  旧时难觅i
    2020-12-11 12:30

    I believe the HTML Purifier Library will work nicely:

    http://htmlpurifier.org/

    HTML Purifier is a standards-compliant HTML filter library written in PHP. HTML Purifier will not only remove all malicious code (better known as XSS) with a thoroughly audited, secure yet permissive whitelist, it will also make sure your documents are standards compliant, something only achievable with a comprehensive knowledge of W3C's specifications. Tired of using BBCode due to the current landscape of deficient or insecure HTML filters? Have a WYSIWYG editor but never been able to use it? Looking for high-quality, standards-compliant, open-source components for that application you're building? HTML Purifier is for you!

提交回复
热议问题