java – OWASP HTML Sanitizer清除注释
发布时间:2020-12-15 00:39:19 所属栏目:Java 来源:网络整理
导读:我有应用程序,客户可以存储以下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" h
我有应用程序,客户可以存储以下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策略以通过以下方式禁止恶意html标记: new HtmlPolicyBuilder().allowElements("link").allowAttributes("rel","type","media","href").onElements("link").toFactory(); 但在卫生设施之后,如果浏览器线路被丢弃. 您能否建议如何配置策略以便存储此类内容? 解决方法
OWASP Sanitizer无法配置为接受这些标记.相反,你可以使用像JSoup这样的HTML解析器在santizing之前提取这些行,然后再添加它们.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |