2

我正在使用 anti-samy 1.5.2 版本将我的 html 转换为安全的 html。

现在我给反samy扫描方法提供以下代码

<a href='http://gmail.com' onclick="window.open(this.href,'','resizable=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,fullscreen=no,dependent=no,status'); return false">gmail.com</a>

但反萨米会将其转换为以下

<a href="http://javaEra.com">javaEra.com</a>

因此,我的 onclick 在我的应用程序中不起作用所以我想要我给 antisamy 的相同代码

谁能帮我?

这是我用于锚标记的反 samy 策略文件

  <tag name="a" action="validate">

        <!--  onInvalid="filterTag" has been removed as per suggestion at OWASP SJ 2007 - just "name" is valid -->
        <attribute name="href"/>
        <attribute name="nohref">
            <regexp-list>
                <regexp name="anything"/>
            </regexp-list>
        </attribute>
        <attribute name="rel">
            <literal-list>
                <literal value="nofollow"/>
            </literal-list>
        </attribute>
        <attribute name="name"/>
        <attribute name="target" onInvalid="filterTag">
            <literal-list>
                <literal value="_blank"/>
                <literal value="_top"/>
                <literal value="_self"/>
                <literal value="_parent"/>
            </literal-list>
        </attribute>
    </tag>
4

1 回答 1

1

最后我得到了这个解决方案:只需将以下属性添加到锚标记在上面的代码替换如下

   <tag name="a" action="validate">

    <!--  onInvalid="filterTag" has been removed as per suggestion at OWASP SJ 2007 - just "name" is valid -->
    <attribute name="href"/>
    <attribute name="nohref">
        <regexp-list>
            <regexp name="anything"/>
        </regexp-list>
    </attribute>
    <attribute name="rel">
        <literal-list>
            <literal value="nofollow"/>
        </literal-list>
    </attribute>
    <attribute name="name"/>
    <attribute name="target" onInvalid="filterTag">
        <literal-list>
            <literal value="_blank"/>
            <literal value="_top"/>
            <literal value="_self"/>
            <literal value="_parent"/>
        </literal-list>
    </attribute>
    <attribute name="onclick">
       <regexp-list>
            <regexp name="anything"/>
        </regexp-list>
    </attribute>
</tag>

itys 现在工作。

于 2014-01-28T10:16:15.927 回答