当前位置: 移动技术网 > IT编程>开发语言>PHP > 如何解决CI框架的Disallowed Key Characters错误提示

如何解决CI框架的Disallowed Key Characters错误提示

2019年04月07日  | 移动技术网IT编程  | 我要评论
用ci框架时,有时候会遇到这么一个问题,打开网页,只显示 disallowed key characters 错误提示。有人说 url 里有非法字符。但是确定 url 是纯英文的,问题还是出来了。但清空浏览器历史记录和cookies后。 刷新就没问题了。有时候。打开不同的浏览器。有的浏览器会有问题。有的就不会。

解决 codeigniter 框架应用中,出现disallowed key characters错误提示的方法。找到/system/core文件夹下的input文件,将下面的代码:
复制代码 代码如下:

function _clean_input_keys($str)
{
    if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str))
    {
        exit('disallowed key characters.');
    }
    // clean utf-8 if supported
    if (utf8_enabled === true)
    {
        $str = $this->uni->clean_string($str);
    }
    return $str;
}

改为:
复制代码 代码如下:

function _clean_input_keys($str)  
{  
    $config = &get_config('config');  
    if ( ! preg_match("/^[".$config['permitted_uri_chars']."]+$/i", rawurlencode($str)))  
    {  
        exit('disallowed key characters.');  
    }  

    // clean utf-8 if supported
    if (utf8_enabled === true)
    {
        $str = $this->uni->clean_string($str);
    }
    return $str;  
}

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网