开发者

XSS Prevention, Tidy vs Purifier?

开发者 https://www.devze.com 2023-01-04 09:18 出处:网络
Greetings, I\'m trying to prevent XSS and improper html from input fields using CKEditor (a javascript WYSIWYG editor).

Greetings,

I'm trying to prevent XSS and improper html from input fields using CKEditor (a javascript WYSIWYG editor).

How should I filter this data on the server side? The two options I'm comparing are PHP Tidy and HTML Purifier. I'm interested in speed, security, and valid nesting.

Edit:

According to HTML Purifier, Tidy does not pre开发者_开发问答vent XSS. So, let me specify that I would first pass the user input through

strip_tags($input,'<img><a><li><ol><ul><b><br>'); before passing to Tidy


HTML Purifier restricts the input beyond what strip_tags can. strip_tags would not strip JavaScript from the attributes of the tags you are allowing. I definitely recommend using HTML Purifier. HTML Purifier is not fast, but add/edit executions are usually less frequent than views so performance is less of an issue.

0

精彩评论

暂无评论...
验证码 换一张
取 消