Codeigniter - Prohibited key, corrective code

Our site was hit by a ddos ​​attack, and some rejected cookies were sent. We use the CodeIgniter structure. Since it is not practical to ask our users to clear their cookies, I was wondering what would have consequences for changing the next function in the kernel. The cookies that create the error take the form:

__utmt_~1

Original function:

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

What are the possible side effects if I change it to allow ~? I know that here to prevent malicious users, and I want to make sure that this will not have undesirable consequences.

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

, CI

application/core/MY_Input.php

php, $config ['subclass_prefix'] "MY _"

<?php
if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class MY_Input extends CI_Input {

    function _sanitize_globals() {

        // Avoid error come from cookie __utmt_~1, it set by Google Analatics
        foreach($_COOKIE as $key => $val) {
            if (strpos($key, '~') !== false) {
                unset($_COOKIE[$key]);
            }
        }

        parent::_sanitize_globals();
    }
}
+1

@Kristian , , :

, , CodeIgniter , , , , CodeIgniter.

0

All Articles