restful路由规则解析BUG

浏览:1234 发布日期:2014/02/18
3.2 - 严重 - 未处理
在手册关于restful路由的部分这样描述:
为了确保定义不冲突,REST路由定义我们通常改成下面的定义方式:array('blog/:id','blog/read','status=1',array('ext'=>'xml','method'=>'get')),
array('blog/:id','blog/update','',array('ext'=>'xml','method'=>'put')),
实际上在路由解析类中并不能正确识别常量REQUEST_METHOD,导致在如下判断中出现bugforeach ($routes as $rule=>$route){
                // ....
                if(is_array($route) && isset($route[2])){
                    // 路由参数
                    $options    =   $route[2];
                    // 原来的代码
                    //if(isset($options['method']) && REQUEST_METHOD != $options['method']){
//正确的代码:
if(isset($options['method']) && strtoupper(I('server.REQUEST_METHOD')) != strtoupper($options['method'])){
                        // 请求类型检测
                        continue;
                    }
                    //........                   
                }
}
评论(
后面还有条评论,点击查看>>