asp过滤代码
❶ ASP字符过滤。
username=trim(request.form("username"))
'定义一个数组
badCode="<,%,@,upload"
'分割数据
badCode=split(badCode,",")
'从第一个循环到最后一回个
for i = 0 to ubound(badCode)
username=replace(username,badCode(i),"") '把这些字符替换为答空
next
❷ 求asp字符串过滤防止sql注入等安全选项的过滤代码
这个函数可以解决
Function SafeRequest(ParaName,ParaType)
'--- 传入参数 ---
'ParaName:参数名称-字符型
'ParaType:参数类型-数字型(1表示以版上参数是数权字,0表示以上参数为字符)
Dim ParaValue
ParaValue=Request(ParaName)
If ParaType=1 then
If not isNumeric(ParaValue) then
Response.write "参数" & ParaName & "必须为数字型!"
Response.end
End if
Else
ParaValue=replace(ParaValue,"'","''")
End if
SafeRequest=ParaValue
End function
❸ asp代码 怎么过滤脏话呀
a=Split("zh","v")
这里你怎么会这样写啊
应该这样
a=Split(zh,"v")
*************分隔符***************下面是我改过的
你看看
x=request("title")
y=request("body")
....(中间省略回)
zh="脏话答Av脏话Bv脏话Cv脏话D"
a=Split(zh,"v")
for i=0 to UBound(a)
y=Replace(y,a(i),"***")
next
response.Write y
❹ 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
'调用
str=RemoveHTML(str)
%>
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/qingflyer/archive/2009/03/20/4007901.aspx
❺ asp过滤所有的html代码函数
应该是可以过掉所有的标签的.大小写已经忽略,全局已经打开,多行也打开着,看了一下你的匹配式回也答是正确的啊.你过不掉的可能是因为中间有空间,而[^>]表示的是不包含>的所有字符.怎么会过滤不掉呢?
"<[\/]?\w+(\s+\w+\=[\"]?\w+[\"]?)*[\/]?>"
这样试试如何
❻ asp 过滤字符串中的某些字符
循环读取每一行放在数组里面
s="[00:02.00]歌曲:月半小夜曲"
s=left(s,5)&right(s,len(s)-8)
response.write s
❼ asp 过滤html代码 保留div p href 等标记
给你一个我采用的例子,你自己想过滤什么标签随便加就行了。
如下:
<%
'过滤回html标签函数答
Function Delhtml(Con,Code)
Do while instr(lcase(con),"<"&Code)
ps = instr(lcase(Con),"<"&Code)
pe = instr(ps,Con,">")+1
p = mid(con,ps,pe-ps)
con = replace(Con,p,"")
Loop
Con = replace(Con,"</"&lcase(Code)&">","")
Con = replace(Con,"</"&ucase(Code)&">","")
Delhtml = Con
End Function
'以下是调用 想过滤什么直接往后加 Str 变量是网页字符串
Str = Delhtml(Str,"img") '过滤图片
Str = Delhtml(Str,"br") '过滤换行
……
%>
❽ 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过滤html代码
我给你写了个方法,你看着用吧。<%Function DropHTML(str)
Dim regEx
Set regEx=New RegExp
regEx.Pattern="<.*>(.+)</\w+>"
regEx.Global=True
regEx.IgnoreCase=True
DropHTML=regEx.Replace(str, "$1")
End Function dim htmlStr, newStrhtmlStr="<font color=#00ff00>依然家族创专始属</font>"newStr=DropHTML(htmlStr)Response.Write(newStr)'输出:依然家族创始%>
❿ asp中用过滤html代码,但要保留p标记
^调用这个方抄法就可以了:
Function replaceWithoutP(ContentStr)
Dim ClsTempLoseStr,regEx
ClsTempLoseStr = Cstr(ContentStr)
Set regEx = New RegExp
regEx.Pattern = "(<(\/){0,1}[^袭<>p]*>)|(<(\/){0,1}[^<>]+p[^<>]*>)"
regEx.IgnoreCase = True
regEx.Global = True
ClsTempLoseStr = regEx.Replace(ClsTempLoseStr,"")
replaceWithoutP = ClsTempLoseStr
Set regEx = Nothing
End Function
兄弟你可以试一下
其中(<(\/){0,1}[^<>p]*>)|(<(\/){0,1}[^<>]+p[^<>]*>)的意思是:以<或者</开头,内容不包含<和>和p,以>结尾;或者以<或者</开头内容包含p但是p前面有别的字符p后面为任意字符,以>结尾
把这些字符串都替换掉就得到你要的结果了