Mehdi Raash
Mehdi Raash

Reputation: 8985

CodeIgniter with Firefox and Disallowed Key Characters

Recently I downloaded codeIgniter 2.1.1. I droped the CI files on my wamp on windows 7, After that simply I opened up firefox and type localhost and I saw this message "Disallowed Key Characters" But, I do not have this problem with Chrome and Opera.

Upvotes: 2

Views: 4193

Answers (4)

blackmambo
blackmambo

Reputation: 152

The answer lies in your browser cookies. I found this entry in mine

'instance0|ab'

Maybe its in your browser. Delete all your cookies and make sure they are gone.

Upvotes: 1

Reza Mamun
Reza Mamun

Reputation: 6189

I was having the same error!

There is the code in system/core/Input.php on line 729.

Just adding a '.' and '|' will allow to pass:

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

This worked for me on my windows localhost with a sub-directory setup :)

Upvotes: 0

Dilip Rajkumar
Dilip Rajkumar

Reputation: 7074

I had similar problem, I cleared all the cookie and then relaunch. Site worked correctly. It may happen because of poorly formed cookie. Hopefully it helps someone..

Upvotes: 0

Lawrence Cherone
Lawrence Cherone

Reputation: 46602

There is this code in system/core/Input.php on line 728:

<?php 
/**
    * Clean Keys
    *
    * This is a helper function. To prevent malicious users
    * from trying to exploit keys we make sure that keys are
    * only named with alpha-numeric text and a few other items.
    *
    * @access   private
    * @param    string
    * @return   string
    */
function _clean_input_keys($str)
{
    if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str))
    {
        exit('Disallowed Key Characters.');
    }

    // Clean UTF-8 if supported
    if (UTF8_ENABLED === TRUE)
    {
        $str = $this->uni->clean_string($str);
    }

    return $str;
}
?>

It checks the keys in key=>value pairs eg: example.com?key=value if your key is not within the range of a-z0-9:_/- it will throw that error.

Change exit('Disallowed Key Characters.');

to exit('Disallowed Key Characters.'.$str); to give you an idea about what key is at fault. Remember this perhaps is checking cookies through $_REQUEST/$_COOKIE so its also a good idea to clear your cookies, perhaps from an older script or version on the same path.

hope it helps

Upvotes: 6

Related Questions