可能重复:
CodeIgniter禁止关键字符
我有一个问题,我正在尝试提交一个表单,它的动态和复选框值来自数据库,唯一的问题是其中一个字段有一个#,当我尝试提交表单时,它返回'disallowed key characters'.
我怎样才能提交#?
它被硬编码到函数_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;
}
Run Code Online (Sandbox Code Playgroud)
根据你的问题,似乎你在表单中使用get作为一种方法,因为它给出了disallowed key characters错误.
要允许字符#只需在CONFIG文件中添加以下内容-
$config['permitted_uri_chars'] = '\#';
Run Code Online (Sandbox Code Playgroud)
现在,字符#将被允许在网址中.
| 归档时间: |
|
| 查看次数: |
43400 次 |
| 最近记录: |