求ASP过滤JS调用的代码,防js注入

来源:百度知道 编辑:UC知道 时间:2024/07/06 16:16:32
望高手能给与详细的代码

Function Deal(exp)
exp=Replace(exp,"<","<")
exp=Replace(exp,">",">")
exp=Replace(exp,"'","''")
exp=Replace(exp,Chr(13),"<br>")
Deal=exp
End Function

这个方法就可以了,没必要判断那么多。用不出<>这个标记怎么也挂不上,每个HTML标记都会有<>嘛。

' ============================================
'过滤HTML代码
' ============================================
Function RemoveHTML(strText)
strText=strText&""
Dim RegEx
Set RegEx = New RegExp
RegEx.Pattern = "<[^>]*>"
RegEx.Global = True
RemoveHTML = RegEx.Replace(strText, "")
End Function
' ============================================
'过滤脚本代码
' ============================================
Function StripHTML(strHTML)
strHTML=strHTML&""
Dim objRegExp,strOutput
Set objRegExp=N