“不允许的密钥字符” CodeIgniter错误? [英] "Disallowed Key Character" error in CodeIgniter?

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

问题描述


可能重复:

CodeIgniter禁止的键字符


当我检查所有复选框下面)它给我这个错误:


不允许的关键字符



b $ b

这是我的HTML:

 < label> Stability Control< / label>< input type = checkboxclass =largercheckboxname =checkBox [Stability-Control]>< / input>< br / 
< label>氙灯大灯< / label>< input type =checkboxclass =largercheckboxname =checkBox [Xenon-Headlamps]< / input>< br /

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

  $ config ['permitted_uri_chars'] ='az 0-9〜%.: _\-'; 


解决方案

system / core / Input.php 不允许字符。

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

这将允许az AZ 0-9:_ \ / -



类,通过在 / application / core / 中创建一个MY_Input.php文件,然后重新创建该方法并添加任何要允许的字符。有关如何实现此功能的示例,请参见创建核心系统类



但是,你应该小心这个,因为你可以打开不必要的安全漏洞。您最好重写您的表单,以便通过现有的验证。



编辑:本文通过扩展Input类来描述上述问题和解决方案。



已搜索,以下帖子也演示了如何解决同样的问题。




Possible Duplicate:
CodeIgniter Disallowed Key Characters

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

Disallowed Key Character

Here's my 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~%.:_\-';

解决方案

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)) ...

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

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.

Edit: 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错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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