公司门卫保安岗位职责:asp过滤函数的用法问题

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/09 07:06:32
下面这段函数具体怎么用?能不能给个例子?

function checkStr(str)
if isnull(str) then
checkStr = ""
exit function
end if
checkStr=replace(str,"'","")
checkStr=replace(str,";","")
checkStr=replace(str,"--","")
checkStr=replace(str,"<","<")
checkStr=replace(str,">",">")
checkStr=replace(str," "," ")
checkStr=replace(str,"javascript","/javascript")
checkStr=replace(str,"cookie","/cookie")
checkStr=replace(str,"document","/document")
end function

你直接在ASP里调用就行了

比如你现在有一个名为“w”的变量
w的值是被过滤的语句,你想过滤掉w里的“'”、“<”、“javascript”……(也就是上面那个函数的内容)

那么直接用:
df=checkStr(w)
就行了,这就是调用了这个函数
注:df也是一个变量,他的值就是把w的值去掉上面函数中所过滤的那些字符后 的值了。

比如w的值是“javascript000document”(也就是:w="javascript000document")

用:df=checkStr(w)
后,df的值就是“/javascript000/document”了。