一、搜索关键字没有过滤<和>
程序对搜索关键字使用CheckStr函数(位于common/function.asp)进行过滤,CheckStr函数却没有对<和>进行过滤,在给CheckStr增加<和>过滤后发现发表文章就出问题了,浏览时出现了很多的<br>,只能直接修改search.asp文件了,在第44句:SearchContent=CheckStr(Request.QueryString("SearchContent"))后增加如下代码即可。
SearchContent = Replace(SearchContent,">",">")
SearchContent = Replace(SearchContent,"<","<")二、评论关键字过滤严
对评论内容程序中采用了JS进行过滤,使用的是CheckPost函数(位于common/common.js),但实际中并未起到作用,比如很多垃圾广告留言格式都是[ url]www.mzwu.com[ /url],CheckPost都通过了,增强了它的过滤功能后却发表不了文章了:(,看来发表文章时也是用这个函数过滤的,一种思路是写过一个函数,但我很快就发现程序中竟没阻止外部提交!只有前台验证根本不够,打开blogcomm.asp修改如下:
'增加函数firestr
function firestr(strContent)
firestr = false
if instr(strContent,"www")<>instrRev(strContent,"www") then
firestr = true
exit function
end if
if instr(strContent,"url")<>instrRev(strContent,"url") then
firestr = true
exit function
end if
if instr(strContent,"http")<>instrRev(strContent,"http") then
firestr = true
exit function
end if
end function
'postcomm函数内找到post_Message=CheckStr(request.form("Message")),在其后面增加下边语句
If firestr(post_Message)=true then
ReInfo(0)="评论发表错误信息"
ReInfo(1)="<b>内容中含有非法字符!</b><br/><a href=""javascript:history.go(-1);"">请返回重新输入</a>"
ReInfo(2)="ErrorIcon"
postcomm=ReInfo
exit function
end if
评论(0)
暂无评论。