Implementation of HTML-removing functions in ASP-application techniques

Source: Internet
Author: User

This function is necessary, many hackers to make trouble, black database, will inject a lot of virus JS, in storage and display text data, use this function filter, can avoid a lot of trouble

clearhtml Code

' Clear HTML code 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 Code

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

How to use:

Copy Code code as follows:

<%=clearhtml ("<div id=" Codetip ">

The above is the full content of this article, I hope you can enjoy.

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.