2013-10-13 58 views
6

我使用Antisamy验证HTML。我的政策允许iframe,例如youtube视频。问题是 - 如果标签是空的(像这样):antisamy解析器强制关闭标记

<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> 

任何想法?

+0

我知道4年过去了....但不管怎样,可以你记得你是否设法解决这个问题?抓住最后两天的吸管 – Rohan210

回答

0

试试这个 -

<tag name="iframe" action="validate"/> 

和标签添加到这个列表 -

<allowed-empty-tags> 
    <literal-list> 
     <literal value="iframe"/> 
    </literal-list> 
</allowed-empty-tags> 

http://code.google.com/p/owaspantisamy/...

+0

这已完成。我更新我的问题。 Thnks。问题是 - 它验证并正确处理。但是如果标签有空的身体 - 它会被替换为自封闭标签。但是如果是自封的,某些标签(iframe,表单,...)在浏览器中不起作用。 – msangel

+0

好的。尝试在列表中添加一个标签 - '允许空标签'。我已经更新了答案。我希望这有帮助。 –

+0

相同。我已经有了这个。这是允许自封闭标签的响应,但对标签转换没有影响。 – msangel