ASP filter the illegal SQL characters of the function code _ Application Tips

Source: Internet
Author: User
Tags trim
Copy Code code as follows:

'**************************************************
' Function name: R
' Function: Filter illegal SQL characters
' Parameters: Strchar-----The characters to filter
' Return value: Filtered character
'**************************************************
Public Function R (Strchar)
If Strchar = "" Or IsNull (strchar) Then R = "": Exit Function
Dim Strbadchar, Arrbadchar, Tempchar, I
' Strbadchar = ' $,#, ',%,^,&,?, (,), <,>,[,],{,},/,\,;,:, "& Chr (+) &", & Chr (0) & ""
Strbadchar = "+, ',--,%,^,&,?, (,), <,>,[,],{,},/,\,;,:," & Chr (+) & ", & 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.[^>]*|\/a|li|br| B|\/li|\/b|font. [^>]*|\/font) > "
Strcode=re. Replace (Strcode, "[$]")
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
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.