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