有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

使用PolicyFactory后,xss HtmlPolicyBuilder样式不会出现在<tr>和<table>标记中。java代码中的清理

<tr onClick="toggleTable('*****')" style=";cursor:pointer ">
<tr bgcolor="#B7C3F7" id="*****" style="display:table">
<table bgcolor="#8DA0F8" id="*****" style="display:none">
<table bgcolor="#8DA0F8" id="*****" style="display:none">

清理后,html页面样式属性不在table和tr元素下。经过净化的HTML如下所示:

<tr onclick="toggleTable('*****')">
<tr bgcolor="#B7C3F7" id="*****">
<table bgcolor="#8DA0F8" id="*****">
<table bgcolor="#8DA0F8" id="*****">

下面是我试图在tr和table元素下允许style属性的代码片段:

PolicyFactory html = new HtmlPolicyBuilder()
.allowElements("table", "tr")
.allowAttributes("style", "id", "bgcolor").onElements("table")
.allowAttributes("bgcolor", "onClick", "style", "id").onElements("tr")
.allowAttributes("style").globally()
.toFactory(); 
  • 我面临的另一个问题是,额外的tableli标记出现在经过清理的html页面中

任何建议/帮助都将不胜感激。提前谢谢


共 (0) 个答案