一个asp函数, 解决SQL Injection漏洞 - 中国WEB开发者网络 (http://www.webasp.net) -- 技术教程 (http://www.webasp.net/article/) --- 一个asp函数, 解决SQL Injection漏洞 (http://www.webasp.net/article/14/13402.htm) |
| -- 作者:未知 -- 发布日期: 2004-09-24 |
| 函数很简单, 主要是针对字符串和数字两种类型的传入数据分别进行了处理,具体用法:
字符类型的 strUsername = CheckInput(Request(“username“),“s“) 数字类型的 ID = CheckInput(Request(“id“),“i“) 下面是函数 Function CheckInput(str,strType) '函数功能:过滤字符参数中的单引号,对于数字参数进行判断,如果不是数值类型,则赋值0 '参数意义: str ---- 要过滤的参数 ' strType ---- 参数类型,分为字符型和数字型,字符型为"s",数字型为"i" Dim strTmp strTmp = "" If strType ="s" Then strTmp = Replace(Trim(str),"'","''") ElseIf strType="i" Then If isNumeric(str)=False Then str="0" strTmp = str Else strTmp = str End If CheckInput = strTmp End Function |
| webasp.net |