一聚教程网:一个值得你收藏的教程网站

热门教程

asp 过滤html代码程序

时间:2022-07-02 23:11:35 编辑:袖梨 来源:一聚教程网

Function TransferHTML(ByVal source,para)

 Dim objRegExp

 '先换"&"
 If Instr(para,"[&]")>0 Then  source=Replace(source,"&","&")
 If Instr(para,"[<]")>0 Then  source=Replace(source,"<","<")
 If Instr(para,"[>]")>0 Then  source=Replace(source,">",">")
 If Instr(para,"[""]")>0 Then source=Replace(source,"""",""")
 If Instr(para,"[space]")>0 Then source=Replace(source," "," ")
 If Instr(para,"[enter]")>0 Then
  source=Replace(source,vbCrLf,"
")
  source=Replace(source,vbLf,"
")
 End If
 If Instr(para,"[vbCrlf]")>0 Then

  Set objRegExp=New RegExp
  objRegExp.IgnoreCase =True
  objRegExp.Global=True

  objRegExp.Pattern="(()|()|()|()|()|()|()|()|()|()|()|()|()|()|()|()|()|()|()|()|()|()|()|())(x20*(rn|n))"

  source= objRegExp.Replace(source,"$1")

  objRegExp.Pattern="(rn|n)"
  source= objRegExp.Replace(source,"
")

  source=Replace(source,"","")
  source=Replace(source,"","")
  source=Replace(source,"","")
  source=Replace(source,"","")

 End If
 If Instr(para,"[vbTab]")>0 Then source=Replace(source,vbTab,"  ")
 If Instr(para,"[no-asp]")>0 Then
  source=Replace(source,"<"&"%","<"&"%")
  source=Replace(source,"%"&">","%"&">")
 End If
 If Instr(para,"[nofollow]")>0 Then
  source=Replace(source,"  End If
 If Instr(para,"[nohtml]")>0  Then
  Set objRegExp=New RegExp
  objRegExp.IgnoreCase =True
  objRegExp.Global=True
  objRegExp.Pattern="<[^>]*>"
  source= objRegExp.Replace(source,"")
 End If
 If Instr(para,"[filename]")>0  Then
  source=Replace(source,"/","")
  source=Replace(source,"","")
  source=Replace(source,":","")
  source=Replace(source,"?","")
  source=Replace(source,"*","")
  source=Replace(source,"""","")
  source=Replace(source,"<","")
  source=Replace(source,">","")
  source=Replace(source,"|","")
  source=Replace(source," ","")
 End If
 If Instr(para,"[normalname]")>0  Then
  source=Replace(source,"$","")
  source=Replace(source,"(","")
  source=Replace(source,")","")
  source=Replace(source,"*","")
  source=Replace(source,"+","")
  source=Replace(source,",","")
  source=Replace(source,"[","")
  source=Replace(source,"]","")
  source=Replace(source,"{","")
  source=Replace(source,"}","")
  source=Replace(source,"?","")
  source=Replace(source,"","")
  source=Replace(source,"^","")
  source=Replace(source,"|","")
  source=Replace(source,":","")
  source=Replace(source,"""","")
  source=Replace(source,"'","")
 End If
 If Instr(para,"[textarea]")>0 Then
  source=Replace(source,"&","&")
  source=Replace(source,"%","%")
  source=Replace(source,"<","<")
  source=Replace(source,">",">")
 End If
 If Instr(para,"[html-format]")>0 Then
  source=Replace(source,"&","&")
  source=Replace(source,"<","<")
  source=Replace(source,">",">")
  source=Replace(source,"""",""")
 End If
 If Instr(para,"[anti-html-format]")>0 Then
  source=Replace(source,""","""")
  source=Replace(source,"<","<")
  source=Replace(source,">",">")
  source=Replace(source,"&","&")
 End If
 If Instr(para,"[wapnohtml]")>0 Then
  source=Replace(source,"
",vbCrLf)
  source=Replace(source,"
",vbCrLf)
  Set objRegExp=New RegExp
  objRegExp.IgnoreCase =True
  objRegExp.Global=True
  objRegExp.Pattern="(<[^>]*)|([^<]*>)"
  source= objRegExp.Replace(source,"")
  objRegExp.Pattern="(rn|n)"
  source= objRegExp.Replace(source,"
")
 End If
 If Instr(para,"[nbsp-br]")>0 Then
  Set objRegExp=New RegExp
  objRegExp.IgnoreCase =True
  objRegExp.Global=True
  objRegExp.Pattern="<$|<b$|<br$|<br/$"
  source= objRegExp.Replace(source,"")
  objRegExp.Pattern="^br/>|^r/>|^/>|^>"
  source= objRegExp.Replace(source,"")
  objRegExp.Pattern="<br/>"
  source= objRegExp.Replace(source,"
")
  objRegExp.Pattern="&nbsp;"
  source= objRegExp.Replace(source," ")
 End If
 If Instr(para,"[closehtml]")>0 Then
  source=closeHTML(source)
 End If


 TransferHTML=source

End Function

热门栏目