ASP检测是否有不安全字符的Function

  不安全的字符其实很多的,很多人都会过滤掉,现在这写一个,只检测,不过滤的代码出来。。

 

  希望能帮到有需要的朋友。

ASP/Visual Basic Code复制内容到剪贴板
  1. Function Check_Str(Input)   
  2.   
  3.  Output = False  
  4.  If InStr(Input,Chr(32)) Then Output = True '空格   
  5.  If InStr(Input,Chr(33)) Then Output = True '!   
  6.  If InStr(Input,Chr(34)) Then Output = True '"   
  7.  If InStr(Input,Chr(35)) Then Output = True '#   
  8.  If InStr(Input,Chr(36)) Then Output = True '$   
  9.  If InStr(Input,Chr(37)) Then Output = True '%   
  10.  If InStr(Input,Chr(38)) Then Output = True '&   
  11.  If InStr(Input,Chr(39)) Then Output = True ''   
  12.  If InStr(Input,Chr(42)) Then Output = True '*   
  13.  If InStr(Input,Chr(43)) Then Output = True '+   
  14.  If InStr(Input,Chr(44)) Then Output = True ',   
  15.  If InStr(Input,Chr(46)) Then Output = True '.   
  16.  If InStr(Input,Chr(47)) Then Output = True '/   
  17.  If InStr(Input,Chr(58)) Then Output = True ':   
  18.  If InStr(Input,Chr(59)) Then Output = True ':   
  19.  If InStr(Input,Chr(60)) Then Output = True '<   
  20.  If InStr(Input,Chr(61)) Then Output = True '=   
  21.  If InStr(Input,Chr(62)) Then Output = True '>   
  22.  If InStr(Input,Chr(63)) Then Output = True '?   
  23.  If InStr(Input,Chr(64)) Then Output = True '@   
  24.  If InStr(Input,Chr(91)) Then Output = True '[   
  25.  If InStr(Input,Chr(92)) Then Output = True '\   
  26.  If InStr(Input,Chr(93)) Then Output = True ']   
  27.  If InStr(Input,Chr(94)) Then Output = True '^   
  28.  If InStr(Input,Chr(96)) Then Output = True '`   
  29.  If InStr(Input,Chr(123)) Then Output = True '{   
  30.  If InStr(Input,Chr(124)) Then Output = True '|   
  31.  If InStr(Input,Chr(125)) Then Output = True '}   
  32.  If InStr(Input,Chr(126)) Then Output = True '~   
  33.  Check_Str = Output   
  34.     
  35. End Function  

  使用方法:

 

  用Check_Str(字符串变量)进行调用,包含不安全符号返回True,否则返回False

 

  特别说明:

 

  每条判断语句后面都有符号,想去掉某个符号检测,删除或注释掉相应的语句即可。



[上一页]  当前第1页,共1页:[1]   [下一页]

文章来自: 本站原创
Tags: Function ASP 字符 检测
相关日志:
评论: 0 条 | 查看: -
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 点击输入框即可显示验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.