Anti-samy code will avoid the onclick in anchor link

1.2k views Asked by At

I am using anti-samy 1.5.2 version for converting my html to safe html.

Now i am giving a following code to anti-samy scan method

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

but anti samy will convert this into following

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

due to this my onclick is not working in my application So I want same code which i have given to antisamy

Can any one help me?

Here my anti samy policy file for anchor tag

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

There are 1 answers

1
Naresh Kallamadi On

At finally I got the solution for this one: just add folloing attribute to anchor tag In above code replace like below

   <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 working now.