OWASP HTML Sanitizer清除评论

问题描述 投票:7回答:2

我有应用程序,客户可以存储以下html行,以便为实际浏览器加载不同的样式:

<!--[if IE 6]><link rel="stylesheet" type="text/css" media="all" href="default/css/general_ie6.css"><![endif]--> 
<!--[if IE 7]><link rel="stylesheet" type="text/css" media="all" href="default/css/general_ie7.css"><![endif]--> 
<!--[if IE 8]><link rel="stylesheet" type="text/css" media="all" href="default/css/general_ie8.css"><![endif]--> 

此外,我已配置OWASP policy以下列方式禁止恶意html标记:

new HtmlPolicyBuilder().allowElements("link").allowAttributes("rel", "type", "media", "href").onElements("link").toFactory();

但在卫生设施if browser lines被放弃后。

您能否建议如何配置策略以便存储此类内容?

java html xss owasp html-sanitizing
2个回答
2
投票

OWASP Sanitizer无法配置为接受这些标记。相反,你可以使用像JSoup这样的HTML解析器在santizing之前提取这些行,然后再添加它们。


0
投票

Issue #1532: Allow comments to be preserved in HTML。在完成该功能请求或类似功能请求之前,HTML清理程序无法做到这一点。

© www.soinside.com 2019 - 2024. All rights reserved.