Home > php教程 > php手册 > 解决CI框架的Disallowed Key Characters错误提示

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

WBOY
Release: 2016-06-13 11:28:42
Original
1061 people have browsed it

用CI框架时,有时候会遇到这么一个问题,打开网页,只显示 Disallowed Key Characters 错误提示。有人说 url 里有非法字符。但是确定 url 是纯英文的,问题还是出来了。但清空浏览器历史记录和cookies后。 刷新就没问题了。有时候。打开不同的浏览器。有的浏览器会有问题。有的就不会。

解决 CodeIgniter 框架应用中,出现Disallowed Key Characters错误提示的方法。找到/system/core文件夹下的Input文件,将下面的代码:

<span function</span> _clean_input_keys(<span $str</span><span )
{
    </span><span if</span> ( ! <span preg_match</span>("/^[a-z0-9:_\/-]+$/i", <span $str</span><span ))
    {
        </span><span exit</span>('Disallowed Key Characters.'<span );
    }
    </span><span //</span><span  Clean UTF-8 if supported</span>
    <span if</span> (UTF8_ENABLED === <span TRUE</span><span )
    {
        </span><span $str</span> = <span $this</span>->uni->clean_string(<span $str</span><span );
    }
    </span><span return</span> <span $str</span><span ;
}</span>
Copy after login

改为:

<span function</span> _clean_input_keys(<span $str</span><span )   
{   
    </span><span $config</span> = &get_config('config'<span );   
    </span><span if</span> ( ! <span preg_match</span>("/^[".<span $config</span>['permitted_uri_chars']."]+$/i", <span rawurlencode</span>(<span $str</span><span )))   
    {   
        </span><span exit</span>('Disallowed Key Characters.'<span );   
    }   
    
    </span><span //</span><span  Clean UTF-8 if supported</span>
    <span if</span> (UTF8_ENABLED === <span TRUE</span><span )
    {
        </span><span $str</span> = <span $this</span>->uni->clean_string(<span $str</span><span );
    }
    </span><span return</span> <span $str</span><span ;   
}  </span>
Copy after login

参考:http://www.nowamagic.net/librarys/veda/detail/1699

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template