2011-03-24 58 views
3

可能重复:
CodeIgniter Disallowed Key Characters笨 - 不允许的按键字符

我有一点与表单我想提交,其动态和复选框值来一个问题,从数据库中,唯一的问题是其中一个字段有#,当我尝试提交表单时,它将返回'disallowed key characters'

如何提交#

+0

,你能否告诉我们这个领域你的代码? – 2011-03-24 18:11:11

+0

BigJobbies 2011-03-24 18:14:23

+1

如果将其重命名为''-cshharp'',该怎么办? – 2011-03-24 18:18:50

回答

5

根据你的问题,你似乎在使用get作为表单中的方法,并且因为它给出了disallowed key characters错误。

为了让角色#只是增加它在你的CONFIG文件中的以下 -

$config['permitted_uri_chars'] = '\#'; 

现在字符#将在URL被允许。

+1

我试着将其添加到默认行与CI船,所以它最终作为$ config ['permitted_uri_chars'] ='az 0-9〜%。:_ \ - \#'; ...但似乎没有工作 – BigJobbies 2011-03-24 18:24:51

9

它被硬编码到函数_clean_input_keys()中的Input类中。

只需创建一个MY_Input类并覆盖该函数。

/** 
* Clean Keys 
* 
* This is a helper function. To prevent malicious users 
* from trying to exploit keys we make sure that keys are 
* only named with alpha-numeric text and a few other items. 
* 
* @access private 
* @param string 
* @return string 
*/ 
function _clean_input_keys($str) 
{ 
    // if (! preg_match("/^[a-z0-9:_\/-]+$/i", $str)) <---- DEL 
    if (! preg_match("/^[#a-z0-9:_\/-]+$/i", $str)) // <----INS 
    { 
     exit('Disallowed Key Characters.'); 
    } 

    // Clean UTF-8 if supported 
    if (UTF8_ENABLED === TRUE) 
    { 
     $str = $this->uni->clean_string($str); 
    } 

    return $str; 
} 
-2

取代:

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

与此:

 if (! preg_match("/^[#a-z0-9:_|\/-]+$/i", $str)) 

system/core/input.php

+0

不覆盖核心文件。它打破升级 – frostymarvelous 2015-04-15 02:20:48