ASP filtering method, commonly used.

Source: Internet
Author: User
Function htmlencode (t0) If Len (t0) <0 or isarray (t0) Then exit functiont0 = trim (t0) t0 = Re (T0, CHR (9 ),"") '"tab" T0 = Re (T0, CHR (13), "")' press ENTER T0 = Re (T0, CHR (22), "") t0 = Re (T0, CHR (38), "&") '"&" T0 = Re (T0, CHR (32), "")' "" T0 = Re (T0, CHR (34), "") '"" T0 = Re (T0, CHR (37), "%")' "%" T0 = Re (T0, CHR (39), "'")' "" T0 = Re (T0, CHR (42), "*") '"*" T0 = Re (T0, CHR (43), "+") '"+" T0 = Re (T0, CHR (44), ",")' "," T0 = Re (T0, CHR (45) & CHR (45), "--") '"--" T0 = Re (T0, CHR (92 ),"\") '"\" T0 = Re (T0, CHR (40), "(")' "(" T0 = Re (T0, CHR (41 ),")") '")" T0 = Re (T0, CHR (60), "<")' "<" T0 = Re (T0, CHR (62), "> ") '">" T0 = Re (T0, CHR (123), "{")' "{" T0 = Re (T0, CHR (125 ),"}") '} "T0 = Re (T0, CHR (59),"; ")';" T0 = Re (T0, CHR (10) & CHR (10 ), CHR (10) 'replaces line feed T0 = Re (T0, CHR (10), "<br>")' line feed T0 = replacetext (T0, "([& #]) ([a-z0-9] *);", "$1 $2;") if lyq_badtext <> "then T0 = replacetext (T0, "(" & lyq_badtext & ")", string (LEN ("& $1 &"), "*") 'filter katakana (Japanese characters) [\ u30a0-\ u30ff] If is_ SQL thent0 = escape (t0) t0 = replacetext (T0, "% u30 ([A-F] [0-f])", "& # x30 $1;") t0 = Unescape (t0) end ifhtmlencode = t0end Function
 
Function Re(t0,t1,t2)IF Isnull(t2) Then t2=""Re=Replace(t0,t1,t2)End Function
Function ReplaceText(t0,t1,t2)Set regEx=New RegExpregEx.Pattern=t1regEx.IgnoreCase=TrueregEx.Global=TrueReplaceText=regEx.Replace(""&t0&"",""&t2&"")Set regEx=nothingEnd Function

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.