linux中curl 访问接口返回:“Disallowed Key Characters ”(php CI框架)

解决 CodeIgniter 框架应用中,出现Disallowed Key Characters错误提示的方法。找到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;  
}


或:
方式二

function _clean_input_keys($str)
{
    if(preg_match("/^,_[a-z0-9:_\/-]+$/",$str)){
        $str = preg_replace("/,_/","",$str);
    }
    if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str))
    {
        exit('Disallowed Key Characters.'.$str);
    }
    return $str;
}

转载地址:http://www.nowamagic.net/librarys/veda/detail/1699

你可能感兴趣的:(linux中curl 访问接口返回:“Disallowed Key Characters ”(php CI框架))