1

Possible Duplicate:
CodeIgniter Disallowed Key Characters

When I check all the checkboxes (code below) it gives me this error:

Disallowed Key Character

Here's my HTML:

<label>Stability Control </label><input type="checkbox" class="largercheckbox"   name="checkBox[Stability-Control]"></input><br/>
<label>Xenon Headlamps</label><input type="checkbox" class="largercheckbox" name="checkBox[Xenon-Headlamps]"></input><br/>

What's the problem here? I think my config file permits those characters:

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
Community
  • 1
  • 1
osos
  • 2,103
  • 5
  • 28
  • 42

2 Answers2

10

The following function found in system/core/Input.php disallows the characters.

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

This will allow a-z A-Z 0-9 : _ \ / -

You should extend the Input class by creating a MY_Input.php file in /application/core/ and recreate the method and add any characters you wish to allow. See Creating Core System Classes for an example as to how to achieve this.

However you should be careful with this as you could open up unnecessary security holes. You are better off rewriting your form so that it passes the existing validation.

Edit: This article describes both the problem and a solution as described above by extending the Input class.

Having searched, the following posts also demonstrate how this is accomplished to solve the same issue

Community
  • 1
  • 1
Ben Swinburne
  • 25,669
  • 10
  • 69
  • 108
  • No the form method is post, i don't think so – osos Nov 13 '11 at 20:34
  • Apologies, I misinterpreted your question as you mentioned `permitted_uri_chars` which led me to not really read the error message properly. This comes from the Input class rather than the config.php file – Ben Swinburne Nov 13 '11 at 20:42
  • Ok thanks for enlighten me with this, i knew what i had to do – osos Nov 13 '11 at 21:02
  • i didn't give you downvote, i gave up upvote and choose your answer as accepted answer, thanks again – osos Nov 15 '11 at 04:07
  • No problem glad I could help. I was just asking whoever did downvote why so that I could improve my answer if necessary. Ben – Ben Swinburne Nov 15 '11 at 08:28
7

Ok here is my answer

You have to go first to system/core/Input.php and look for a function called

_clean_input_keys($str)

I was don't know what is the character that is disallowed here so when you add the $str like the following

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

you will get exactly the character that cause the problem mine was ' ) ' so you have to do one of the following remove the disallowed character from the html or permit it like @Ben Swinburne said

Hope that help others

osos
  • 2,103
  • 5
  • 28
  • 42