值得收藏的html过滤代码

动网论坛中的HTML过滤代码,值得收藏!
Function HTMLEncode(fString)
 fString=Trim(fString)
 fString=Replace(fString,CHR(9),"")
 fString=Replace(fString,CHR(13),"")
 fString=Replace(fString,CHR(22),"")
 fString=Replace(fString,CHR(38),"&") '“&”
 fString=Replace(fString,CHR(32)," ") '“ ”
 fString=Replace(fString,CHR(34),""") '“"”
 fString=Replace(fString,CHR(37),"%") '“%”
 fString=Replace(fString,CHR(39),"'") '“'”
 fString=Replace(fString,CHR(42),"*") '“*”
 fString=Replace(fString,CHR(43),"+") '“+”
 fString=Replace(fString,CHR(44),",") '“,”
 fString=Replace(fString,CHR(45)&CHR(45),"--") '“--”
 fString=Replace(fString,CHR(92),"\") '“\”
 'fString=Replace(fString,CHR(95),"_") '“_”
 fString=Replace(fString,CHR(40),"(") '“(”
 fString=Replace(fString,CHR(41),")") '“)”
 fString=Replace(fString,CHR(60),"&#60;") '“<”
 fString=Replace(fString,CHR(62),"&#62;") '“>”
 fString=Replace(fString,CHR(123),"&#123;") '“{”
 fString=Replace(fString,CHR(125),"&#125;") '“}”
 fString=Replace(fString,CHR(59),"&#59;") '“;”
 fString=Replace(fString,CHR(10),"<br>")
 fString=ReplaceText(fString,"([&#])([a-z0-9]*)&#59;","$1$2;")
 if SiteConfig("BannedText")<>"" then fString=ReplaceText(fString,"("&SiteConfig("BannedText")&")",string(len("&$1&"),"*"))
 if IsSqlDataBase=0 then '过滤片假名(日文字符)[\u30A0-\u30FF] by yuzi
  fString=escape(fString)
  fString=ReplaceText(fString,"%u30([A-F][0-F])","&#x30$1;")
  fString=unescape(fString)
 end if
 HTMLEncode=fString
End Function

 本文转自 simeon2005 51CTO博客,原文链接:http://blog.51cto.com/simeon/101245

上一篇:手撕面试官系列(十):面试必备之常问Dubbo29题+MySQL55题


下一篇:satellite-menu和ArcMenu