asp過濾
⑴ asp中如何過濾掉特殊字元
|user=replace(trim(request.form("uName")),"'","''")
password=replace(trim(request.form("Password")),"'","''")
if instr(user,"%") or instr(user,"#") or instr(user,"?") or instr(user,"|") or instr(user,"'") then
response.write "<script language=javascript>alert('您的姓名含有非法字元!');this.location.href='login.asp';</script>"
response.end
end if
if instr(password,"%") or instr(password,"#") or instr(password,"?") or instr(password,"|") then
response.write "<script language=javascript>alert('您的密碼含有非法字元!');this.location.href='login.asp';</script>"
response.end
end if 我自己做的,希望對你有幫助
⑵ asp過濾()中間的內容 包括()符號
<%
dim x,x1,x2
x="asp過濾(123456999999999999999999)中間的內內容容"
x1=split(x,"(")
for i=0 to ubound(x1)
Next
x2=split(x1(1),")")
for j=0 to ubound(x2)
Next
response.write x1(0)&x2(1)
%>
⑶ ASP字元過濾。
username=trim(request.form("username"))
'定義一個數組
badCode="<,%,@,upload"
'分割數據
badCode=split(badCode,",")
'從第一個循環到最後一回個
for i = 0 to ubound(badCode)
username=replace(username,badCode(i),"") '把這些字元替換為答空
next
⑷ asp過濾函數的用法問題
你直接在ASP里調用就行了
比如你現在有一個名為「w」的變數
w的值是被過濾的語句,內你想過濾掉w里的「'」、「容<」、「javascript」……(也就是上面那個函數的內容)
那麼直接用:
df=checkStr(w)
就行了,這就是調用了這個函數
註:df也是一個變數,他的值就是把w的值去掉上面函數中所過濾的那些字元後 的值了。
比如w的值是「javascript000document」(也就是:w="javascript000document")
用:df=checkStr(w)
後,df的值就是「/javascript000/document」了。
⑸ ASP過濾函數
正則可以幫你解決
給你一個過濾回答HTML函數
Function RemoveHTML(strHTML)
Dim objRegExp, Match, Matches
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = "<.+?>"
Set Matches = objRegExp.Execute(strHTML)
For Each Match in Matches
strHtml=Replace(strHTML,Match.Value,"")
Next
RemoveHTML=strHTML
Set objRegExp = Nothing
End Function
⑹ asp過濾字元
不知道你的具體需求是什麼,下面給你4個函數,都是很不錯的,你自己看著用吧:
Function HtmlFormat(ByVal str)
If Not IsN(str) Then
Dim m : Set m = RegMatch(str, "<([^>]+)>")
For Each Match In m
str = Replace(str, Match.SubMatches(0), regReplace(Match.SubMatches(0), "\s+", Chr(0)))
Next
Set m = Nothing
str = Replace(str, Chr(32), " ")
str = Replace(str, Chr(9), " ")
str = Replace(str, Chr(0), " ")
str = regReplace(str, "(<[^>]+>)\s+", "$1")
str = Replace(str, vbCrLf, "<br />")
End If
HtmlFormat = str
End Function
Function HtmlEncode(ByVal str)
If Not IsN(str) Then
str = Replace(str, Chr(38), "&")
str = Replace(str, "<", "<")
str = Replace(str, ">", ">")
str = Replace(str, Chr(39), "'")
str = Replace(str, Chr(32), " ")
str = Replace(str, Chr(34), """)
str = Replace(str, Chr(9), " ")
str = Replace(str, vbCrLf, "<br />")
End If
HtmlEncode = str
End Function
Function HtmlDecode(ByVal str)
If Not IsN(str) Then
str = regReplace(str, "<br\s*/?\s*>", vbCrLf)
str = Replace(str, " ", Chr(9))
str = Replace(str, """, Chr(34))
str = Replace(str, " ", Chr(32))
str = Replace(str, "'", Chr(39))
str = Replace(str, "'", Chr(39))
str = Replace(str, ">", ">")
str = Replace(str, "<", "<")
str = Replace(str, "&", Chr(38))
str = Replace(str, "&", Chr(38))
HtmlDecode = str
End If
End Function
Function HtmlFilter(ByVal str)
str = regReplace(str,"<[^>]+>","")
str = Replace(str, ">", ">")
str = Replace(str, "<", "<")
HtmlFilter = str
End Function
Function GetScriptTime(StartTimer)
GetScriptTime = FormatNumber((Timer()-StartTimer)*1000, 2, -1)
End Function
⑺ asp如何過濾傳遞的數據
Function rp(c)
c=Replace(c,"""","")
c=Replace(c,"'","")
c=Replace(c," ","")
c=Replace(c,"%","")
c=Replace(c,"#","")
c=Replace(c,"&","")
c=Replace(c,"*","")
c=Replace(c,"(","")
c=Replace(c,")","")
c=Replace(c,"@","")
c=Replace(c,"`","")
c=Replace(c,"/","")
c=Replace(c,"\","")
c=Replace(c,",","")
c=Replace(c,".","")
c=Replace(c,"=","")
c=Replace(c,"<","")
c=Replace(c,">","")
rp=c
End function
⑻ asp過濾 怎麼寫
<%
Dim str_arr,str_word,noid,badwords
str_arr="<!來-$arr->"
str_word = "賭博源"&st_arr&"黃賭"&st_arr&"海洛因"
str_word_no="**"
content_word="這里是你的文章內容"
badwords=split(str_word,str_arr)
For noid=0 to ubound(badwords)
re_word=badwords(noid)
content_word=content_word&replace(content_word,re_word,str_word_no)
Next
%>
⑼ asp 字元串過濾
我已寫成一個函數,如下:
Function KeyWordAddLink(Byval strText,Byval strReplace)
Dim re,s,i,strKey,strSubKey
set re = New RegExp
re.IgnoreCase = True
re.Global = True
s = strText
strKey = Split(strReplace,"||")
For i = 0 To UBound(strKey)
If strKey(i) <> "" Then
strSubKey = Split(strKey(i),">>")
If strSubKey(0) <> "" Then
re.Pattern = "(^|[^\/\\\w\=])(" & strSubKey(0) & ")"
s=re.Replace(s, "$1<a target=""_blank"" href=""" & strSubKey(1) & """ class=""KeyLink""><font color=""red""><b>$2</b></font></a>")
End If
End If
Next
KeyWordAddLink=s
set re = nothing
End Function
參數strText :被替換的文本
參數strReplace :用來替換的文本
示例:
dim word,replaceStr
word="網路是搜索引擎"
replaceStr="網路>>http://www..com||搜索>>http://www.g.cn"
word = KeyWordAddLink(word,replaceStr)
Response.Write word
結果輸出:
<a target="_blank" href="http://www..com" class="KeyLink"><font color="red"><b>網路</b></font></a>是一個<a target="_blank" href="http://www.g.cn" class="KeyLink"><font color="red"><b>搜索</b></font></a>引擎
⑽ ASP過濾字元串
這兩個函數一個去掉標記和一個不去掉標記:
Function outHTML(str)
Dim sTemp
sTemp = str
outHTML = ""
If IsNull(sTemp) = True Then
Exit Function
End If
sTemp = Replace(sTemp, "&", "&")
sTemp = Replace(sTemp, "<", "<")
sTemp = Replace(sTemp, ">", ">")
sTemp = Replace(sTemp, Chr(34), """)
sTemp = Replace(sTemp, Chr(10), "<br>")
outHTML = sTemp
End Function
Function inHTML(str)
Dim sTemp
sTemp = str
inHTML = ""
If IsNull(sTemp) = True Then
Exit Function
End If
sTemp = Replace(sTemp, "&", "&")
sTemp = Replace(sTemp, "<", "<")
sTemp = Replace(sTemp, ">", ">")
sTemp = Replace(sTemp, Chr(34), """)
inHTML = sTemp
End Function