建站常识

asp中实现清除html的函数,asp清除html函数

发布时间 | 2017/12/11  点击 | 

这个函数是必需要的,很多黑客来捣乱,黑掉数据库,会注入大量的病毒js,在存储和展示文本数据的时候,使用此函数过滤一下,可避免不少麻烦

clearhtml代码

'清除HTML代码
function clearhtml(content)
  content=replacehtml("&#[^>]*;","",content)
  content=replacehtml("]*>","",content)
  content=replacehtml("]*>","",content)
  content=replacehtml("]*>","",content)
  content=replacehtml("]*>","",content)
  content=replacehtml("]*>","",content)
  content=replacehtml(" ","",content)
  content=replacehtml("]*>","",content)
  content=replacehtml("]*>","",content)
  content=replacehtml("]*>","",content)
  content=replacehtml("]*>","",content)
  content=replacehtml("]*>","",content)
  content=replacehtml("]*>","",content)
  content=replacehtml("]*>","",content)
  content=replacehtml("]*>","",content)
  content=replacehtml("]*>","",content)
  content=replacehtml("]*>","",content)
  content=replacehtml("]*>","",content)
  content=replacehtml("]*>","",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("]*>","",content)
  content=replacehtml("]*>","",content)
  content=replacehtml("]*>","",content)
  content=replacehtml("]*>","",content)
  content=replacehtml("]*>","",content)
  content=replacehtml("]*>","",content)
  content=replacehtml("]*>","",content)
  content=replacehtml("]*>","",content)
  content=replacehtml("]*>","",content)
  content=replacehtml("]*>","",content)
  content=replacehtml("]*>","",content)
  content=replacehtml("]*>","",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

相关信息