1

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!

Nick
  • 111
  • 2
  • 6

2 Answers2

2

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.

Charity Leschinski
  • 2,886
  • 2
  • 23
  • 40
Visavì
  • 2,333
  • 1
  • 21
  • 29
  • Thanks for this explanation. This appears to be new in Codeigniter 2.1.0. I was able to use the "@" symbol in the older version. – Nick Feb 20 '12 at 17:30
0

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.

Kai Qing
  • 18,793
  • 5
  • 39
  • 57
  • It's still not working. This is so odd. It works fine in my older projects, but not this one. I literally just started this, so I can't think of anything that might be causing it. – Nick Feb 17 '12 at 20:38