首页 > 其他 > 详细

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

时间:2014-12-08 14:02:38      阅读:225      评论:0      收藏:0      [点我收藏+]

防止SQL注入,将特殊符号转换为其他字符

Function htmlspecialchars(str)
    str = replace(str, ">", ">")
    str = replace(str, "<", "&lt;")
    str = Replace(str, CHR(32), "&nbsp;")
    str = Replace(str, CHR(34), "&quot;")
    str = Replace(str, CHR(39), "&#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,""),"&nbsp;","")
End Function

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

原文:http://my.oschina.net/anhoo/blog/353719

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!