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

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

在做项目过程中,出现提交形式表单的时候,出现了不允许的关键字符的提示

打开铸铁框架的源码不难发现,在铸铁的核心投入类中有这样一个函数:

复制代码代码如下:function _ clean _ input _ keys($ str){ if(!preg_match(/^[a-z0-9:_/-] $/i ,$str)) {退出(不允许的关键字符。);}

//Clean UTF-8 if supported if(UTF8 _ ENABLED===TRUE){ $ str=$ this-uni-Clean _ string($ str);}

返回$ str}这是进行过滤的,所以抛出错误

我们在应用的核心中对这个方法进行重写即可命名一个为MY_Input.php(前缀我的_可以在config.php中自定义),然后将下面代码加入即可复制代码代码如下:AI_Input类扩展CI_Input {

//构造函数function _ _ construct(){ parent:_ _ construct();}

function _ clean _ input _ keys($ str){ if(preg_match(/^,_[a-z0-9:_/-]$/,$str)){ $ str=preg _ replace(/,_/,,$ str);}

如果(!preg_match(/^[a-z0-9:_/-] $/i ,$str)) {退出(不允许的关键字符。。$ str);} return $ str}}

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