asp下过滤非法的SQL字符的函数代码

来源:asp之家 时间:2011-03-03 11:23:00 

过滤非法的SQL字符的函数代码:


'************************************************** 
'函数名:R 
'作 用:过滤非法的SQL字符 
'参 数:strChar-----要过滤的字符 
'返回值:过滤后的字符 
'************************************************** 
Public Function R(strChar) 
If strChar = "" Or IsNull(strChar) Then R = "":Exit Function 
Dim strBadChar, arrBadChar, tempChar, I 
'strBadChar = "$,#,',%,^,&,?,(,),<,>,[,],{,},/,\,;,:," & Chr(34) & "," & Chr(0) & "" 
strBadChar = "+,',--,%,^,&,?,(,),<,>,[,],{,},/,\,;,:," & Chr(34) & "," & Chr(0) & "" 
arrBadChar = Split(strBadChar, ",") 
tempChar = strChar 
For I = 0 To UBound(arrBadChar) 
tempChar = Replace(tempChar, arrBadChar(I), "") 
Next 
tempChar = Replace(tempChar, "@@", "@") 
R = tempChar 
End Function 
'过滤xss 
Function CheckXSS(ByVal strCode) 
Dim Re 
Set re=new RegExp 
re.IgnoreCase =True 
re.Global=True 
re.Pattern="<.[^>]*(style).>" 
strCode = re.Replace(strCode, "") 
re.Pattern="<(a.[^>]*|\/a|li|br|B|\/li|\/B|font.[^>]*|\/font)>" 
strCode=re.Replace(strCode,"[$1]") 
strCode=Replace(Replace(strCode, "<", "<"), ">", ">") 
re.Pattern="\[(a.[^\]]*|\/a|li|br|B|\/li|\/B|font.[^\]]*|\/font)\]" 
strCode=re.Replace(strCode,"<$1>") 
re.Pattern="<.[^>]*(on(load|click|dbclick|mouseover|mouseout|mousedown|mouseup|mousewheel|keydown|submit|change|focus)).>" 
strCode = re.Replace(strCode, "") 
Set Re=Nothing 
CheckXSS=strCode 
End Function 

Function FilterIDs(byval strIDs) 
Dim arrIDs,i,strReturn 
strIDs=Trim(strIDs) 
If Len(strIDs)=0 Then Exit Function 
arrIDs=Split(strIDs,",") 
For i=0 To Ubound(arrIds) 
If ChkClng(Trim(arrIDs(i)))<>0 Then 
strReturn=strReturn & "," & Int(arrIDs(i)) 
End If 
Next 
If Left(strReturn,1)="," Then strReturn=Right(strReturn,Len(strReturn)-1) 
FilterIDs=strReturn 
End Function

标签:asp,过滤,SQL字符
0
投稿

猜你喜欢

  • python实现猜数字游戏

    2022-12-23 17:30:06
  • Django权限机制实现代码详解

    2022-09-18 01:21:51
  • tensorflow实现对图片的读取的示例代码

    2023-07-20 06:07:30
  • Python之csv文件从MySQL数据库导入导出的方法

    2023-08-09 04:45:10
  • PHP使用flock实现文件加锁的方法

    2023-10-29 21:26:59
  • Bootstrap中的表单验证插件bootstrapValidator使用方法整理(推荐)

    2024-04-10 13:53:57
  • Python模拟鼠标点击实现方法(将通过实例自动化模拟在360浏览器中自动搜索python)

    2021-06-11 17:17:54
  • python爬取豆瓣评论制作词云代码

    2023-03-14 04:31:40
  • go语言优雅地处理error工具及技巧详解

    2023-07-16 18:56:56
  • GIT相关-IDEA/ECLIPSE工具配置的教程详解

    2023-06-27 21:12:53
  • Python新手学习函数默认参数设置

    2021-08-18 03:50:35
  • JavaScript中 this 指向问题深度解析

    2024-05-03 15:04:14
  • python 设置输出图像的像素大小方法

    2023-09-02 04:24:39
  • python接口,继承,重载运算符详解

    2023-03-08 05:51:38
  • 使用SQL语句去掉重复的记录【两种方法】

    2024-01-18 16:55:59
  • 朴素贝叶斯算法的python实现方法

    2023-03-01 07:05:53
  • 使用JavaScript实现网页版Pongo设计思路及源代码分享

    2024-04-10 10:48:07
  • 从MySQL数据库表中取出随机数据的代码

    2023-11-14 09:53:58
  • Vue项目中keepAlive的使用说明(超级实用版)

    2024-05-02 16:34:02
  • Python微信库:itchat的用法详解

    2022-02-17 10:54:33
  • asp之家 网络编程 m.aspxhome.com