过滤sql特殊字符

function POP_sqlin(text)  
  if isnull(text) then
    POP_sqlin=""
    exit function
  end if

  dim Sqlwords
  Set Sqlwords=new RegExp
  Sqlwords.IgnoreCase =True
  Sqlwords.Global=True

  Sqlwords.Pattern="(')"
  text=Sqlwords.Replace(text,"''")
  Sqlwords.Pattern="(;)"
  text=Sqlwords.Replace(text,";")
  Sqlwords.Pattern="(%)"
  text=Sqlwords.Replace(text,"%")
  Sqlwords.Pattern="(and)"
  text=Sqlwords.Replace(text,"and")
  Sqlwords.Pattern="(exec)"
  text=Sqlwords.Replace(text,"exec")
  Sqlwords.Pattern="(execute)"
  text=Sqlwords.Replace(text,"execute")
  Sqlwords.Pattern="(insert)"
  text=Sqlwords.Replace(text,"insert")
  Sqlwords.Pattern="(select)"
  text=Sqlwords.Replace(text,"select")
  Sqlwords.Pattern="(delete)"
  text=Sqlwords.Replace(text,"delete")
  Sqlwords.Pattern="(update)"
  text=Sqlwords.Replace(text,"update")
  Sqlwords.Pattern="(count)"
  text=Sqlwords.Replace(text,"count")
  Sqlwords.Pattern="(chr)"
  text=Sqlwords.Replace(text,"chr")
  Sqlwords.Pattern="(mid)"
  text=Sqlwords.Replace(text,"mid")
  Sqlwords.Pattern="(master)"
  text=Sqlwords.Replace(text,"master")
  Sqlwords.Pattern="(truncate)"
  text=Sqlwords.Replace(text,"truncate")
  Sqlwords.Pattern="(char)"
  text=Sqlwords.Replace(text,"char")
  Sqlwords.Pattern="(declare)"
  text=Sqlwords.Replace(text,"declare")

  Set Sqlwords=Nothing
  POP_sqlin = text
end function

function POP_sqlout(text)  
  if isnull(text) then
    POP_sqlout=""
    exit function
  end if
  text = Replace(text,"''","'")
  text = Replace(text,";",";")
  text = Replace(text,"%","%")
  text = Replace(text,"and","and")
  text = Replace(text,"exec","exec")
  text = Replace(text,"execute","execute")
  text = Replace(text,"insert","insert")
  text = Replace(text,"select","select")
  text = Replace(text,"delete","delete")
  text = Replace(text,"update","update")
  text = Replace(text,"count","count")
  text = Replace(text,"chr","chr")
  text = Replace(text,"mid","mid")
  text = Replace(text,"master","master")
  text = Replace(text,"truncate","truncate")
  text = Replace(text,"char","char")
  text = Replace(text,"declare","declare")
  POP_sqlout = text
end function

function HTMLEncode(popstring)
  if not isnull(popstring) then
  popstring = POP_sqlout(popstring)
  popstring = replace(popstring, ">", ">")
  popstring = replace(popstring, "<", "<")
  popstring = Replace(popstring, CHR(32), " ")
  popstring = Replace(popstring, CHR(9), " ")
  popstring = Replace(popstring, CHR(34), """)
  popstring = Replace(popstring, CHR(39), "'")
  popstring = Replace(popstring, CHR(10) & CHR(10), "</p><p> ")
  popstring = Replace(popstring, CHR(10), "<br /> ")
  popstring = Replace(popstring, CHR(36), "$")
  HTMLEncode = popstring
  end if
end function

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值