What happened to CodeIgniter disallowed key characters?

Explain the function of static keyword and final keyword in Java in detail>>>

I believe that many people encounter the problem of disallowed key characters, even when visiting CSDN, because the part of the web page of CSDN is written in CI, the problem lies in the class of CI processing submission string. Even if it’s just a domain name. There are no special characters. The problem is still with us. Why

This is related to the design of the string processing class of CI. It is like this: the strings submitted through the get and post methods are handled by the system/core/input.php class. Many people ask why such an error is reported when there is no special symbol in the URL, because you omit the string transmitted by cookie and session, In other words, the data of get, post, cookie and session are all processed by this class, and the problems often appear on the cookie and session. Therefore, many people on the Internet provide the method of clearing the cache and cookie, which is really no problem, but there are problems again after a period of time, Because the newly generated cookie contains strings that are not matched, how can we solve this problem

Since the problem occurs in the input. PHP class, just modify it_ clean_ input_ Keys method

function_ clean_ input_ keys($str)

{

if(! preg_ match(“/^[a-z0-9:_\/-]+$/ i”,$str))

{

exit(‘DisallowedKeyCharacters.’);

}

//CleanUTF-8ifsupported

if(UTF8_ ENABLED===TRUE)

{

$str=$this-> uni-> clean_ string($str);

}

return$str;

}

Change to:

function_ clean_ input_ keys($str)

{

/*if(! preg_ match(“/^[a-z0-9:_\/-]+$/ i”,$str))

{

exit(‘DisallowedKeyCharacters.’);

}*/

$config=& get_ config(‘config’);

if(! emptyempty($config[‘permitted_ uri_ chars’]))

{

if(! preg_ match(“/^[“.$config[‘permitted_ uri_ chars’].”]+$/i”,rawurlencode($str)))

{

exit(‘DisallowedKeyCharacters.’);

}

}

//CleanUTF-8ifsupported

if(UTF8_ ENABLED===TRUE)

{

$str=$this-> uni-> clean_ string($str);

}

return$str;

}

Then add the following in config/config.php:

$config[‘permitted_ uri_ chars’]=’a-z0-9~%.:_\-‘;

Change to:

$config[‘permitted_ uri_ chars’]=”;

That’s it

Since then, the problem has been solved, and those who don’t understand can understand the above code, hoping to help

Similar Posts: