Not allowing “@” symbol in Codeigniter URL

2019-08-04 04:38发布

I'm trying to get Codeigniter to accept the "@" symbol in a URL. I've included it as one of the permitted characters below:

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_@-';

Yet I continue to get his error message:

Disallowed Key Characters.

Every other character seems to be working fine except for the "@" symbol. Any ideas?

Thanks!

2条回答
一纸荒年 Trace。
2楼-- · 2019-08-04 04:50

Did you add proper escaping to your permitted uri string?

$config['permitted_uri_chars'] = 'a-z 0-9~%\.\:_\-';

I copied this right from one of my CI sites and %40 is allowed.

Please refer to pekka's comment above about the actual @ symbol.

查看更多
贼婆χ
3楼-- · 2019-08-04 05:06

The CodeIgniter routing system translates your url to define controller, action and parameters as keys/values. It checks if the value of a key has permitted characters, and you can configure this with the $config['permitted_uri_chars'], but the error message you get is about the key itself not about its value. The $config['permitted_uri_chars'] doesn't help you to allow the @ symbol in this case. You will find the function function _clean_input_keys($str) that checks the keys in system/core/input.php. The % character is not allowed so '%40' will not pass:

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

The only way around this in your case is to avoid this character (maybe translating it) in key parameters.

查看更多
登录 后发表回答