用户
 找回密码
 入住 CI 中国社区
搜索
查看: 6610|回复: 2
收起左侧

[已解决] The URI you submitted has disallowed characters.错误的另外一种原因

[复制链接]
发表于 2010-8-19 22:46:46 | 显示全部楼层 |阅读模式
php5.3.1 preg_quote对-也进行了转义 ,如果自己写支持中文的uri函数请使用文中的 preg_match替换网上常见的方法
网上支持中文的my_uri.php
<?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))   
{   
exit('The URI you submitted has disallowed characters.');   
}   
$str = urldecode($str);  
}   
return $str;   
}   
  
}  

?>
替换文中的红色为  : ! preg_match("|^[".str_replace(array('\\-', '\-'), '-', preg_quote($this->config->item('permitted_uri_chars'), '-'))."]+$|i", $str)
即可解决php5.3版本提示  The URI you submitted has disallowed characters.的错误
发表于 2011-10-9 11:17:21 | 显示全部楼层
感谢啦 ,解决问题!  
这样不会有安全问题吧?
发表于 2011-11-4 15:09:31 | 显示全部楼层
很好很强大

本版积分规则