Function Code for filtering invalid SQL characters in asp

Source: Internet
Author: User

Copy codeThe Code is as follows: '*************************************** ***********
'Function name: R
'Usage: Filter invalid SQL characters
'Parameter: strChar ----- the character to be filtered
'Return value: filtered characters
'*************************************** ***********
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
'Filter 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 | li | br | B | \/li | \/B | font. [^>] * | \/font)>"
StrCode = re. Replace (strCode, "[$1]")
StrCode = Replace (strCode, "<", "<"), ">", "> ")
Re. pattern = "\ [(. [^ \] * | \/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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.