php 5.3下跟CI 1.7.2配合时"The URI you submitted has disallowed characters"错误的解决

php 5.3的最新版本时,跟CI 1.7.2配合时,有时会出现:
The URI you submitted has disallowed characters的错误,
解决方法如下:
主要是因为preg_quote是在每个允许的字符前加了一个反斜杠:
让a-z 0-9变成了“a\-z 0\-9″,解决为,
在libraries目录下,设置为my_uri.php
class MY_URI extends CI_URI {  
function _filter_uri($str)  
{  
if ($str != '' AND $this->config->item('permitted_uri_chars') != '')  
{  
$str = urlencode($str);  
         //   if ( ! preg_match("|^[".preg_quote($this->config->item('permitted_uri_chars'))."]+$|i", $str))  
if ( ! preg_match("|^[".($this->config->item('permitted_uri_chars'))."]+$|i", rawurlencode($str)))
{  
exit('The URI you submitted has disallowed characters.');  
}  
$str = urldecode($str); 
}  
return $str;  
}  

注意的是,去掉preg_quote函数,而在
config.php中:
$config['permitted_uri_chars'] = 'a-z 0-9~%\.\:_\-';

你可能感兴趣的:(PHP)