防止注入、清除、过滤函数

为什么80%的码农都做不了架构师?>>>   hot3.png

防止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), "

")
    str = Replace(str, CHR(10), "
")
    htmlspecialchars = str
End Function

过滤图片采用函数
function noImg(str)
dim re
Set re=new RegExp
re.IgnoreCase =true
re.Global=True
re.Pattern="(\)"
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

转载于:https://my.oschina.net/anhoo/blog/353719

你可能感兴趣的:(防止注入、清除、过滤函数)