加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > PHP > 正文

CodeIgniter框架提示Disallowed Key Characters的解决办法

发布时间:2020-05-24 09:49:47 所属栏目:PHP 来源:互联网
导读:在做项目过程中,出现提交form表单的时候,出现了Disallowed Key Characters 的提示

打开ci框架的源码不难发现,在ci的核心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;
}
这是进行过滤的,所以抛出错误

我们在application的core中对这个方法进行重写即可
命名一个为MY_Input.php(前缀MY_可以在config.php中自定义),然后将下面代码加入即可
代码如下:class AI_Input extends CI_Input { //构造函数
function __construct(){
parent::__construct();
} 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;
}
}

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读