注:
1.对于单标记(如:<hr />,<br />等),因其对网站本身不会构成威胁,故未将单标记纳过过滤范围。
2.参数strhtml:待过滤处理的html代码内容
3.参数strtags:为待过滤掉的html标记名,各标记名以英文逗号( , )为间隔
复制代码 代码如下:
<%
'wrtten by i{at}cnlei.com
function lfilterbadhtml(byval strhtml,byval strtags)
dim objregexp,stroutput
dim arrtag,i
arrtag=split(strtags,",")
set objregexp = new regexp
stroutput=strhtml
objregexp.ignorecase = true
objregexp.global = true
for i=0 to ubound(arrtag)
objregexp.pattern = "<"&arrtag(i)&"[\s\s]+</"&arrtag(i)&"*>"
stroutput = objregexp.replace(stroutput, "")
next
set objregexp = nothing
lfilterbadhtml = stroutput
end function
'wrtten by i{at}cnlei.com
function lfilterbadhtml(byval strhtml,byval strtags)
dim objregexp,stroutput
dim arrtag,i
arrtag=split(strtags,",")
set objregexp = new regexp
stroutput=strhtml
objregexp.ignorecase = true
objregexp.global = true
for i=0 to ubound(arrtag)
objregexp.pattern = "<"&arrtag(i)&"[\s\s]+</"&arrtag(i)&"*>"
stroutput = objregexp.replace(stroutput, "")
next
set objregexp = nothing
lfilterbadhtml = stroutput
end function
'example
dim spagecont
spagecont= "...网页正文内容..."
spagecont=filterbadhtml(spagecont,"script,iframe,object,table")
%>