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

yipeiwu_com6年前PHP代码库
用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;  
}

相关文章

分享最受欢迎的5款PHP框架

分享最受欢迎的5款PHP框架

1. CodeIgniter Framework   CodeIgniter 是目前使用最广泛的 PHP 框架。CodeIgniter 是一个简单快速的PHP MVC 框架。...

The specified CGI application misbehaved by not returning a complete set of HTTP headers

是错误报告: The specified CGI application misbehaved by not returning a complete set of HTTP heade...

php采用curl模仿登录人人网发布动态的方法

本文实例讲述了php采用curl模仿登录人人网发布动态的方法。分享给大家供大家参考。具体实现方法如下: 说到php中模仿登录很多人第一时间会想到curl函数系列了,这个没错本例子也是使用...

php调用云片网接口发送短信的实现方法

php调用云片网接口发送短信的实现方法 云片网发送短信 /** * [SendSms description] * @param [string] $tpl_conten...

php在window iis的莫名问题的测试方法

假设php安装在c:\php,在cmd 里面测试php是否有配置问题 复制代码 代码如下:c:\php\php.exe -i看下是否有一些错误蹦出来 然后调整 php.ini...