- 資訊首頁(yè) > 開(kāi)發(fā)技術(shù) > web開(kāi)發(fā) > ASP >
- asp中實(shí)現清除html的函數
這個(gè)函數是必需要的,很多黑客來(lái)?yè)v亂,黑掉數據庫,會(huì )注入大量的病毒js,在存儲和展示文本數據的時(shí)候,使用此函數過(guò)濾一下,可避免不少麻煩
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);">添加完代碼必須點(diǎn)擊“完成并查看”生效</li><li>準確的編程語(yǔ)言,可正確對代碼語(yǔ)法著(zhù)色</li><li>輸入簡(jiǎn)單幾個(gè)字的代碼片段說(shuō)明</li><li>上傳源碼文件時(shí)無(wú)需再輸入說(shuō)明</li><li>非程序相關(guān)文件將直接刪除,嚴重封帳號</li><li>圖片僅用來(lái)上傳截圖之類(lèi)的文件,勿作他途</li></ul></div>")%>
以上就是本文所述的全部?jì)热萘?,希望大家能夠喜歡。
免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng )、來(lái)自本網(wǎng)站內容采集于網(wǎng)絡(luò )互聯(lián)網(wǎng)轉載等其它媒體和分享為主,內容觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如侵犯了原作者的版權,請告知一經(jīng)查實(shí),將立刻刪除涉嫌侵權內容,聯(lián)系我們QQ:712375056,同時(shí)歡迎投稿傳遞力量。
Copyright ? 2009-2022 56dr.com. All Rights Reserved. 特網(wǎng)科技 特網(wǎng)云 版權所有 特網(wǎng)科技 粵ICP備16109289號
域名注冊服務(wù)機構:阿里云計算有限公司(萬(wàn)網(wǎng)) 域名服務(wù)機構:煙臺帝思普網(wǎng)絡(luò )科技有限公司(DNSPod) CDN服務(wù):阿里云計算有限公司 百度云 中國互聯(lián)網(wǎng)舉報中心 增值電信業(yè)務(wù)經(jīng)營(yíng)許可證B2
建議您使用Chrome、Firefox、Edge、IE10及以上版本和360等主流瀏覽器瀏覽本網(wǎng)站