antisamy解析器强制关闭标签 [英] antisamy parser force closing tag

查看:251
本文介绍了antisamy解析器强制关闭标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Antisamy来验证HTML。我的政策允许iframe,例如youtube视频。问题是 - 如果标签为空(如下所示):

I use Antisamy for validating HTML. My policy allow iframes, like youtube videos. Problem is - if tag is empty(like this):

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

但它应该有正常的结束标记。

But it should have normal closing tag.

这打破了页面上的所有内容。
我已经将我的指令设置为使用大部分HTML而不是XML:

And this break all content on page after. I already set my directives to use most of HTML but not 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:在解析器之间切换和使用指令仍然没有给出任何结果。

UPD: switching between parsers and playing with directives still did not give any results.

UPD2:这是我的配置的一部分,负责处理 iframe 标签:

UPD2: this is part of my configuration, responsible for handling iframe tag:

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

有什么想法吗?

推荐答案

试试这个 -

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

并在此列表中添加标签 -

And add a tag to this list -

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

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

这篇关于antisamy解析器强制关闭标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆