Search code examples
codeignitercsrf

CodeIgniter: Disallowed Key Characters


I have the same problem as the people below, but the solutions offered for them does not work for me.

CodeIgniter - disallowed key characters

CodeIgniter Disallowed Key Characters

Disallowed key characters error message in Codeigniter (v2)

I get "Disallowed Key Characters" when I submit a form.

I have CSRF protection enabled, and I am using arrays in my form field names (i.e., search[] as the name as there are multiple selection dropdown options). I have a feeling it is the "[]" in the form name that bothers this form.

I have followed all advice I could see in the posts above.

  1. I disabled CSRF temporarily,
  2. I disabled XSS temporarily,
  3. I edited $config['permitted_uri_chars'] and
  4. I edited Input.php where this message is generated.

Anybody has any additional ideas of what could cause this problem on form submission?

Thanks!


Solution

  • Thanks, but I found a comment hidden way below (right at the bottom at the time of this writing) on another post here: CodeIgniter Disallowed Key Characters

    The comment suggested that I add $str to the exit() comment to test. This indicated that I had a missing double quote in my form fields. It is a very complex form built up dynamically, with 300 lines of code, so easy to miss.

    Hope this answer (and the comment that inspired it) helps someone else.

    Validating the source of the output could prevent problems such as this one :-)

    Regards