一个asp函数, 解决SQL Injection漏洞
程序员文章站
2022-05-14 10:06:19
函数很简单, 主要是针对字符串和数字两种类型的传入数据分别进行了处理,具体用法:字符类型的strusername = checkinput(request(“username“),“s“)数字类型的...
函数很简单, 主要是针对字符串和数字两种类型的传入数据分别进行了处理,具体用法:
字符类型的
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
字符类型的
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
上一篇: 构造函数的继承
下一篇: WPF学习笔记(2):准确定位弹出窗