Pagedown(WMD 编辑器)Java Sanitizer(或 OWASP xml 规则)
我在客户端使用著名的 wmd-javascript 编辑器 PageDown 的重新实现(它也在 Stackoverflow 上使用)。
现在,我正在为我的服务器(运行 tomcat7)搜索 HTML 清理程序,它应该只过滤 PageDown 编辑器可以创建的 HTML 子集。
我的第一个选择是 OWASP 项目,但我没有找到 PageDown 的 xml 规则文件 - tinymce 的规则文件限制太多,因为它不包含“img”标签等。
建立自己的一套规则不仅非常痛苦,而且还给我带来了安全问题。出于这个原因,我想询问是否有 Java 类或 OWASP 规则或其他东西也已经过测试。
非常感谢您的帮助!
提前谢谢, 托马斯
I'm using the reimplementation of the famous wmd-javascript editor PageDown on client side (which is also used on Stackoverflow).
Now, I'm searching an HTML sanitizer for my server (runs tomcat7) which should only filter the HTML-subset that the PageDown editor can create.
My first choice was the OWASP project but I didn't found a xml rule file for PageDown - the rule-file for tinymce was too restrictive because it didn't include e.g. an "img"-tag.
Building my own set of rules is not only quite painful, it gives me security concerns. For this reason I wanted to ask if there are Java-classes or OWASP-Rules or something else out there which also have been tested.
Help would be very appreciated!
Thx in advance,
Thomas
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用
JSoup
。它允许您将生成的
HTML
中所需的元素列入白名单。请参阅 jsoup_cookbook_cleaning-html_whitelist-sanitizer
You can use
JSoup
.Its allows you to whitelist the elements you want in the resulting
HTML
.See jsoup_cookbook_cleaning-html_whitelist-sanitizer
使用 HTML Purifier、html5lib 或专门为 HTML 清理而构建的其他系统。 (既然您询问了 OWASP:好的将使用允许的标签、属性和其他语法的 OWASP 白名单。)
Use HTML Purifier, html5lib, or another system built specifically for HTML sanitization. (Since you asked about OWASP: The good ones will use the OWASP whitelist of allowed tags, attributes, and other syntax.)
OWASP 的新 HTML Sanitizer 不需要您在XML 配置语言。
它附带预可以联合在一起的打包策略,如果您想要执行自定义策略,则可以在 Java 代码中执行此操作。
OWASP's new HTML Sanitizer doesn't require you to maintain rules in an XML configuration language.
It comes with pre-packaged policies which can be unioned together, and if you want to do a custom policy, you can do that in Java code.