CodeIgniter禁用键字符 [英] CodeIgniter Disallowed Key Characters

查看:96
本文介绍了CodeIgniter禁用键字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CodeIgniter给我一个 Disallowed Key Characters 错误。我把它缩小到一个表单字段的名称属性: name ='prod [50-4121.5]'但我不知道该怎么办。

CodeIgniter is giving me a Disallowed Key Characters error. I've narrowed it down to the name attribute of a form field: name='prod[50-4121.5]' but I'm not sure what to do about it.

推荐答案

打开 libraries / Input.php code> function _clean_input_keys($ str){,整个块应该看起来像所以:

Open libraries/Input.php (system/core/Input.php in CI version 2.0+) and locate function _clean_input_keys($str){, The whole block should look like so:

function _clean_input_keys($str)
{
    if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str))
    {
        exit('Disallowed Key Characters.');
    }

    return $str;
}

修改PCRE sot以允许新的字符。

Modify the PCRE sot that it allows the new chars.

请注意,缺少的字符是(点),应该总是转义。 / code>(点),因为它们将允许任何单个字符。

Please not that the char thats missing is the .(dot) and you should always escape the .(dot) in Regular Expressions as they will otherwise allow any single char.

/^[a-z0-9:_\/-\.]+$/i

这篇关于CodeIgniter禁用键字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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