【发布时间】:2013-10-21 00:04:46
【问题描述】:
我使用 Antisamy 来验证 HTML。我的政策允许 iframe,例如 youtube 视频。问题是 - 如果标签是空的(像这样):
<iframe src="//www.youtube.com/embed/uswzriFIf_k?feature=player_detailpage" allowfullscreen></iframe>
清洗后会是这样的:
<iframe src="//www.youtube.com/embed/uswzriFIf_k?feature=player_detailpage" allowfullscreen/>
但它应该有正常的结束标记。
这会破坏页面上的所有内容。 我已经将指令设置为使用大部分 HTML 但不使用 XML:
<directives>
<directive name="omitXmlDeclaration" value="true"/>
<directive name="omitDoctypeDeclaration" value="true"/>
<directive name="maxInputSize" value="200000"/>
<directive name="nofollowAnchors" value="true" />
<directive name="validateParamAsEmbed" value="true" />
<directive name="useXHTML" value="false"/>
<directive name="embedStyleSheets" value="false"/>
<directive name="connectionTimeout" value="5000"/>
<directive name="maxStyleSheetImports" value="3"/>
<directive name="formatOutput" value="false"/>
</directives>
但这无济于事。
UPD:在解析器之间切换和使用指令仍然没有给出任何结果。
UPD2:这是我配置的一部分,负责处理iframe标签:
<tag name="iframe" action="validate">
<attribute name="src">
<regexp-list>
<regexp name="youtube"/>
<regexp name="slideshare"/>
</regexp-list>
</attribute>
<attribute name="allowfullscreen">
<regexp-list>
<regexp name="anything"/>
</regexp-list>
</attribute>
<attribute name="scrolling">
<regexp-list>
<regexp name="anything"/>
</regexp-list>
</attribute>
<attribute name="marginwidth">
<regexp-list>
<regexp name="anything"/>
</regexp-list>
</attribute>
<attribute name="marginheight">
<regexp-list>
<regexp name="anything"/>
</regexp-list>
</attribute>
<attribute name="frameborder">
<regexp-list>
<regexp name="anything"/>
</regexp-list>
</attribute>
<attribute name="style"/>
</tag>
有什么想法吗?
【问题讨论】:
-
我知道 4 年过去了....但是,你能记得你是否设法解决了这个问题吗?这两天一直在抓稻草
标签: java security html-parsing owasp antisamy