推荐一个被大家忽视的微软的反跨站脚本库Anti-XSS V3.1

    每个项目都在无休无止的用到跨站脚本过滤,大家都是自己写,于是各种各样的正则表达式层出不尽。

    推荐的这个微软的反跨站脚本库,个人感觉是非常棒的,也不再需要为自己的代码是否过滤完全而绞尽脑汁了。

    文件名:Microsoft Anti-Cross Site Scripting Library V3.1

    下载地址:http://www.microsoft.com/downloads/details.aspx?FamilyId=051ee83c-5ccf-48ed-8463-02f56a6bfc09&displaylang=en

    微软反跨站脚本库V3.1的(反跨站脚本3.1版本)是一种编码库,旨在帮助保护开发人员保护他们的基于Web的应用不被XSS攻击。 

    请查看它的接口,以帮助您确定在编码时使用适当的调用方法,过滤可能包含不受信任的输出。

 

编码方法

使用场景

示例

HtmlEncode(String)

不受信任的HTML代码。 <a href=”http://www.cnblogs.com”>Click Here [不受信任的输入]</a>
HtmlAttributeEncode(String)

 

不受信任的HTML属性

<hr noshade size=[不受信任的输入]>

JavaScriptEncode(String)

不受信任的输入在JavaScript中使用

<script type=”text/javascript”>

[Untrusted input]

</script>

UrlEncode(String)

 

不受信任的URL

<a href=”http://cnblogs.com/results.aspx?q=[Untrusted input]”>Cnblogs.com</a>

VisualBasicScriptEncode(String)

不受信任的输入在VBScript中使用

<script type=”text/vbscript” language=”vbscript”>

[Untrusted input]

</script>

XmlEncode(String)

不受信任的输入用于XML输出

<xml_tag>[Untrusted input]</xml_tag>

XmlAttributeEncode(String)

 

不 受信任的输入用作XML属性

<xml_tag attribute=[Untrusted input]>Some Text</xml_tag>

 使用方法:

在项目中引用"AntiXSSLibrary.dll"即可,大家也可以上MS网站下载它的安装文件。

附上类库和使用手册:AntiXSSLibrary.rar

 

posted @ 2010-03-04 00:23  木子博客  阅读(3069)  评论(7编辑  收藏  举报