2011-03-24 55 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