“不允许的关键字符"CodeIgniter 中的错误? [英] "Disallowed Key Character" error in CodeIgniter?

查看:30
本文介绍了“不允许的关键字符"CodeIgniter 中的错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
CodeIgniter 禁止的关键字符

当我选中所有复选框(下面的代码)时,它给了我这个错误:

When I check all the checkboxes (code below) it gives me this error:

不允许的关键字符

这是我的 HTML:

<label>Stability Control </label><input type="checkbox" class="largercheckbox"   name="checkBox[Stability-Control]"></input><br/>
<label>Xenon Headlamps</label><input type="checkbox" class="largercheckbox" name="checkBox[Xenon-Headlamps]"></input><br/>

这里有什么问题?我认为我的配置文件允许这些字符:

What's the problem here? I think my config file permits those characters:

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_-';

推荐答案

system/core/Input.php 中的以下函数不允许字符.

The following function found in system/core/Input.php disallows the characters.

function _clean_input_keys($str) {
    if ( ! preg_match("/^[a-z0-9:_/-]+$/i", $str)) ...

这将允许 a-z A-Z 0-9 : _ /-

This will allow a-z A-Z 0-9 : _ / -

您应该通过在 /application/core/ 中创建一个 MY_Input.php 文件来扩展 Input 类,然后重新创建该方法并添加您希望允许的任何字符.有关如何实现此目标的示例,请参阅创建核心系统类.

You should extend the Input class by creating a MY_Input.php file in /application/core/ and recreate the method and add any characters you wish to allow. See Creating Core System Classes for an example as to how to achieve this.

但是,您应该小心这一点,因为您可能会打开不必要的安全漏洞.你最好重写你的表单,让它通过现有的验证.

However you should be careful with this as you could open up unnecessary security holes. You are better off rewriting your form so that it passes the existing validation.

这篇文章通过扩展 Input 类来描述上述问题和解决方案.

This article describes both the problem and a solution as described above by extending the Input class.

经过搜索,以下帖子还演示了如何完成此操作以解决相同的问题

Having searched, the following posts also demonstrate how this is accomplished to solve the same issue

CodeIgniter - 不允许使用的关键字符

这篇关于“不允许的关键字符"CodeIgniter 中的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆