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

[HELP] 1.7.1中,按以前的uri支持中文方法好像不行

[复制链接]
发表于 2009-10-11 10:39:57 | 显示全部楼层 |阅读模式
不知道谁有解决办法,我按扩展的方法试,好像不行。
发表于 2009-10-11 11:28:06 | 显示全部楼层
你是如何扩展的?
发表于 2009-10-13 16:04:12 | 显示全部楼层
直接修改URI的类库算了   ci\system\libraries\URI.PHP

PHP复制代码
        function _filter_uri($str)
        {
                if ($str != '' && $this->config->item('permitted_uri_chars') != '' && $this->config->item('enable_query_strings') == FALSE)
                {
                        // preg_quote() in PHP 5.3 escapes -, so the str_replace() and addition of - to preg_quote() is to maintain backwards
                        // compatibility as many are unaware of how characters in the permitted_uri_chars will be parsed as a regex pattern
                       $str = urlencode($str);//解决中文URI                        if ( ! preg_match("|^[".str_replace(array('\\-', '\-'), '-', preg_quote($this->config->item('permitted_uri_chars'), '-'))."]+$|i", $str))
                        {
                                show_error('The URI you submitted has disallowed characters.', 400);
                        }
                        $str = urldecode($str);
                }
 
                // Convert programatic characters to entities
                $bad        = array('$',                 '(',                 ')',                 '%28',                 '%29');
                $good        = array('$',        '(',        ')',        '(',        ')');
 
                return str_replace($bad, $good, $str);
        }
 
复制代码

其实支不支持中文就是看有没有进行编码    在这里加上urlencode之后再加上urldecode就OK了

评分

参与人数 1威望 +3 收起 理由
Hex + 3 我很赞同

查看全部评分

 楼主| 发表于 2009-10-15 10:14:54 | 显示全部楼层
学习了,这个方法最简单

本版积分规则