修正了URL 控制器的一小bug
先看代码,<?phpclass Test extends Controller {
function Test()
{
parent::Controller();
}
function get($a,$b)
{
echo $a.$b;
}
}
?>
如果在浏览器上直接传输
index.php/test/get/1/2
可以正常显示成12
如果传递中文变量
index.php/test/get/1/中国
CI报错提示:The URI you submitted has disallowed characters.
可以用下面的方法暂时解决,修改\libraries/URL.php 189行(1.6.3)
if ( ! preg_match("|^[".preg_quote($this->config->item('permitted_uri_chars'))."]+$|i", $str))
为
if ( ! preg_match("|^[".preg_quote($this->config->item('permitted_uri_chars'))."]+$|i", urlencode($str)))
不过暂时只能支持在UTF-8的编码上,还请哪位高人能提供更好的解决方案
[ 本帖最后由 路过人间 于 2008-6-30 10:19 编辑 ] 先看
CI basedir/system/application/config/config.php
$config['permitted_uri_chars']
中文字符默认本来就不在permitted_url里面
这点没有问题,不是bug
但问题是通过配置好像还是无法让中文通过,这点到真是他的设计不周
我觉得preg_quote不需要处理,都是自己配置还过滤啥啊? 这个我发现了,但确实目前的配置不允许让中文通过啊。:Q 关键还是正则要写好,我觉得不能算 BUG 吧。 确实不算是BUG,只是觉得作者没有考虑太周全而已。。
难道这就是人们常说的,程序的“用户体验”?
页:
[1]