url重写:恶意url导致死循环

问题

url重写,用户输入一个随意url可能导致出现死循环,如http://xxx/xxx/ddd.!@#$

结果如

原因是因为正则表达式不够精确导致此结果:

本人之前采用

<rule>
       <from>/jsp/postBlog</from>
       <to>/jsp/postBlog.action</to>
   </rule>

的规则,导致输入http://localhost:8080/iustest/jsp/postBlog.html造成死循环

解决方法:更改rule

<rule>
       <from>^/jsp/postBlog$</from>
       <to>/jsp/postBlog.action</to>
   </rule>

问题解决。输入http://localhost:8080/iustest/jsp/postBlog.html报404错误,不会进入死循环了

分析原因:

/jsp/postBlog      意思是:包含"/jsp/postBlog"字符内容就能被检索,如"/jsp/postBlog.html"

^/jsp/postBlog$  意思是:只有包含"/jsp/postBlog"字符内容就能被检索,而"/jsp/postBlog.html"不能被匹配到 

 

 

 

 

posted @ 2013-04-18 19:17  君子笑而不语  阅读(263)  评论(0编辑  收藏  举报