这个函数是必需要的,很多黑客来捣乱,黑掉数据库,会注入大量的病毒js,在存储和展示文本数据的时候,使用此函数过滤一下,可避免不少麻烦
clearhtml代码
'清除HTML代码
function clearhtml(content)
content=replacehtml("&#[^>]*;","",content)
content=replacehtml("</?marquee[^>]*>","",content)
content=replacehtml("</?object[^>]*>","",content)
content=replacehtml("</?param[^>]*>","",content)
content=replacehtml("</?embed[^>]*>","",content)
content=replacehtml("</?table[^>]*>","",content)
content=replacehtml(" ","",content)
content=replacehtml("</?tr[^>]*>","",content)
content=replacehtml("</?th[^>]*>","",content)
content=replacehtml("</?p[^>]*>","",content)
content=replacehtml("</?a[^>]*>","",content)
content=replacehtml("</?img[^>]*>","",content)
content=replacehtml("</?tbody[^>]*>","",content)
content=replacehtml("</?li[^>]*>","",content)
content=replacehtml("</?span[^>]*>","",content)
content=replacehtml("</?div[^>]*>","",content)
content=replacehtml("</?th[^>]*>","",content)
content=replacehtml("</?td[^>]*>","",content)
content=replacehtml("</?script[^>]*>","",content)
content=replacehtml("(javascript|jscript|vbscript|vbs):","",content)
content=replacehtml("on(mouse|exit|error|click|key)","",content)
content=replacehtml("<\\?xml[^>]*>","",content)
content=replacehtml("<\/?[a-z]+:[^>]*>","",content)
content=replacehtml("</?font[^>]*>","",content)
content=replacehtml("</?h[^>]*>","",content)
content=replacehtml("</?u[^>]*>","",content)
content=replacehtml("</?i[^>]*>","",content)
content=replacehtml("</?center[^>]*>","",content)
content=replacehtml("</?center[^>]*>","",content)
content=replacehtml("</?nobr[^>]*>","",content)
content=replacehtml("</?clk[^>]*>","",content)
content=replacehtml("</?muti[^>]*>","",content)
content=replacehtml("</?/option[^>]*>","",content)
content=replacehtml("</?o[^>]*>","",content)
content=replacehtml("</?strong[^>]*>","",content)
clearhtml=content
end function
replacehtml代码
function replacehtml(patrn,strng,content)
if isnull(content) then
content=""
end if
set regex=new regexp
regex.pattern=patrn
regex.ignorecase=true
regex.global=true
replacehtml=regex.replace(content,strng)
end function
使用方法:
代码如下:
<%=clearhtml("<div id="CodeTip"><h2>分享代码提示(2)</h2><ul><li style="font-weight: bold; color: rgb(170, 0, 0);">添加完代码必须点击“完成并查看”生效</li><li>准确的编程语言,可正确对代码语法着色</li><li>输入简单几个字的代码片段说明</li><li>上传源码文件时无需再输入说明</li><li>非程序相关文件将直接删除,严重封帐号</li><li>图片仅用来上传截图之类的文件,勿作他途</li></ul></div>")%>
以上就是本文所述的全部内容了,希望大家能够喜欢。
您可能感兴趣的文章:ASP 时间函数及如何获取服务器时间的写法Asp Split函数之使用多个分割符的方法asp与js的类型转换函数介绍asp中的Rnd 函数ASP转换格林威治时间函数DateDiff()应用ASP移动文件函数movefile权限不足的替代方法ASP中实现的URLEncode、URLDecode自定义函数asp实现获取MSSQL数据库表指定条件行数的函数asp实现截取字符串函数ASP实现强制图片下载函数ASP函数大全解析