首页 > 代码库 > 防止注入、清除、过滤函数
防止注入、清除、过滤函数
防止SQL注入,将特殊符号转换为其他字符
Function htmlspecialchars(str)
str = replace(str, ">", ">")
str = replace(str, "<", "<")
str = Replace(str, CHR(32), " ")
str = Replace(str, CHR(34), """)
str = Replace(str, CHR(39), "'")
str = Replace(str, CHR(13), "")
str = Replace(str, CHR(10) & CHR(10), "</P><P>")
str = Replace(str, CHR(10), "<BR>")
htmlspecialchars = str
End Function
过滤图片采用函数
function noImg(str)
dim re
Set re=new RegExp
re.IgnoreCase =true
re.Global=True
re.Pattern="(\<img[^\<]*\>)"
str=re.replace(str," ")
noImg=str
set re=nothing
end function
清除HTML格式采用函数
Function RemoveHTML( strText )
Dim regEx
Set regEx = New RegExp
regEx.Pattern ="(<[^>]*?>)"
regEx.Global = True ‘搜索全部匹配
regEx.IgnoreCase = True ‘是否区分大小写
RemoveHTML = replace(regEx.Replace(""&strText,"")," ","")
End Function
防止注入、清除、过滤函数