CI框架出现Disallowed Key Characters错误怎么办

2023-04-20

这篇文章给大家分享的是有关CI框架出现Disallowed Key Characters错误怎么办的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

用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;   
}

感谢各位的阅读!关于“CI框架出现Disallowed Key Characters错误怎么办”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

《CI框架出现Disallowed Key Characters错误怎么办.doc》

下载本文的Word格式文档,以方便收藏与打印。