[Import] common ASP functions: HTMLFilter ()

Source: Internet
Author: User

<%
'Filter various HTML Tag style scripts
'Source: http://jorkin.reallydo.com/article.asp? Id = 521
'Need RegReplace function: http://jorkin.reallydo.com/article.asp? Id = 345

Function HTMLFilter (sHTML, sFilters)
If sHTML & "" = "" Then Exit Function
If sFilters & "" = "" Then sFilters = "SCRIPT, OBJECT"
Dim aFilters
AFilters = Split (UCase (sFilters ),",")
For I = 0 To UBound (aFilters)
Select Case UCase (Trim (aFilters (I )))
Case "JORKIN"
Do While instr (shtml, "& nbsp;")> 0
Shtml = Replace (shtml, "& nbsp;", "& nbsp ;")
Loop
Case "script"
'// Remove the script <scr ept> </scr EPT> and onload.
Shtml = regreplace (shtml, "<SCRIPT [\ s] *? </SCRIPT> ","")
Shtml = regreplace (shtml, "\ s [on]. +? = \ S +? ([\ "" | \ ']) (. *?) \ 1 ","")
Shtml = regreplace (shtml, "(JavaScript | JScript | VBScript | vbs):", "$1 :")
Case "fiximg"
Shtml = regreplace (shtml, "] *). *?> "," ")
Shtml = regreplace (shtml, " "," ")
Case "table"
'// Remove the table <table> <tr> <td> <th>
SHTML = RegReplace (sHTML, "</? TABLE [^>] *> ","")
SHTML = RegReplace (sHTML, "</? TBODY [^>] *> ","")
SHTML = RegReplace (sHTML, "<(/?) TR [^>] *> "," <$1 p> ")
SHTML = RegReplace (sHTML, "</? TH [^>] *> ","")
SHTML = RegReplace (sHTML, "</? TD [^>] *> ","")
Case "CLASS"
'// Remove the Style class = ""
SHTML = RegReplace (sHTML, "(<[^>] +) CLASS = [^ | ^>] + ([^>] *> )", "$1 $2 ")
SHTML = RegReplace (sHTML, "\ sCLASS \ s *? = \ S *? ([\ "" | \ ']) (. *?) \ 1 ","")
Case "STYLE"
'// Remove the style = ""
Shtml = regreplace (shtml, "(<[^>] +) style = [^ | ^>] + ([^>] *> )", "$1 $2 ")
Shtml = regreplace (shtml, "\ sstyle \ s *? = \ S *? ([\ "" | \ ']) (. *?) \ 1 ","")
Case "XML"
'// Remove XML <? XML>
Shtml = regreplace (shtml, "<\\? XML [^>] *> ","")
Case "namespace"
'// Remove the namespace <O: P> </O: P>
Shtml = regreplace (shtml, "<\/? [A-Z] +: [^>] *> ","")
Case "font"
'// Remove the font <font> </font>
Shtml = regreplace (shtml, "</? Font [^>] *> ","")
Case "marquee"
'// Subtitle removal <marquee> </marquee>
SHTML = RegReplace (sHTML, "</? MARQUEE [^>] *> ","")
Case "OBJECT"
'// Remove the object <object> <param> <embed> </object>
SHTML = RegReplace (sHTML, "</? OBJECT [^>] *> ","")
SHTML = RegReplace (sHTML, "</? PARAM [^>] *> ","")
SHTML = RegReplace (sHTML, "</? EMBED [^>] *> ","")
Case "COMMENT"
'// Remove HTML comments. The <script> and <style> comments are processed with caution.
SHTML = RegReplace (sHTML, "<! -- [\ S \ S] *? --> ","")
Case Else
'// Remove other labels
SHTML = RegReplace (sHTML, "</? "& AFilters (I) &" [^>] *?> ","")
End Select
Next
Htmlfilter = shtml
End Function
%>

Source: http://Jorkin.Reallydo.Com/default.asp? Id = 521

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.