The problem of implementing the function to clear html in Asp has stumped many users. So let’s take a look at the method of clearing html functions in Asp with the editor of Foxin. For those who don’t know yet, please refer to it.
This function is necessary. Many hackers will mess up and hack the database and inject a large amount of virus js. When storing and displaying text data, use this function to filter it to 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("</?embed[^>]*>","",content) content=replacehtml("</?table[^>]*>","",content) content=replacehtml("",content) content=replacehtml("</?tr[^>]*>","",content) content=replacehtml("</?th[^>]*>","",content) content=replacehtml("</?p[^>]*>","",content) content=replacehtml("</?li[^>]*>","",content) content=replacehtml("</?li[^>]*>","",content) content=replacehtml("</?li[^>]*>","",content) content=replacehtml("</?li[^>]*>","",content) content=replacehtml("</?span[^>]*>","",content) content=replacehtml("</?div[^>]*>","",content) content=replacehtml("</?th[^>]*>","",content) content=replacehtml("</?td[^>]*>","",content) content=replacehtml("</?td[^>]*>","",content) content=replacehtml("(javascript|jscript|vbscript|vbs):","",content) content=replacehtml("on(mouse|exit|error|click|key)","",content) content=replacehtml("</?xml[^>]*>","",content) content=replacehtml("</?u[^>]*>","",content) content=replacehtml("</?i[^>]*>","",content) content=replacehtml("</?i[^>]*>","",content) content=replacehtml("</?i[^>]*>","",content) content=replacehtml("</?i[^>]*>","",content) content=replacehtml("</?i[^>]*>","",content) content=replacehtml("</?center[^>]*>","",content) content=replacehtml("</?center[^>]*>","",content) content=replacehtml("</?nobr[^>]*>","",content) content=replacehtml("</?o[^>]*>","",content) content=replacehtml("</?o[^>]*>","",content) content=replacehtml("</?o[^>]*>","",content) content=replacehtml("</?o[^>]*>","",content) content=replacehtml("</?strong[^>]*>","",content) clearhtml=contentend functionreplacehtml 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:
The code copy is as follows:<%=clearhtml("<div id="CodeTip"><h2>Share code tips (2)</h2><ul><li style="font-weight: bold; color: rgb(170, 0, 0);">After adding the code, you must click "Finish and view" to take effect</li><li>Accurate programming language, which can correctly color the code syntax</li><li>Input a few simple code snippet description</li><li>No need to enter an explanation when uploading the source code file</li><li>No need to enter an explanation</li><li>Not program-related files will be deleted directly, severely blocked</li><li>Images are only used to upload files such as screenshots, do not use other ways</li></ul></div>")%>
The above is all the content described in this article, I hope you like it. If you have any questions, you can leave a message to communicate