Solution to Disallowed Key Characters prompted by CodeIgniter framework

Source: Internet
Author: User

Open the source code of the ci framework and it is not difficult to find that there is such a function in the core input class of the ci:

Copy codeThe Code is as follows:
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;
}
This is for filtering, so an error is thrown.

We can rewrite this method in the application core.
Name MY_Input.php (the prefix MY _ can be customized in config. php) and add the following code.
Copy codeThe Code is as follows:
Class AI_Input extends CI_Input {

// Constructor
Function _ construct (){
Parent: :__ construct ();
}

Function _ clean_input_keys ($ str)
{
If (preg_match ("/^, _ [a-z0-9: _ \/-] + $/", $ str )){
$ Str = preg_replace ("/, _/", "", $ str );
}

If (! Preg_match ("/^ [a-z0-9: _ \/-] + $/I", $ str ))
{
Exit ('disallowed Key Characters. '. $ str );
}
Return $ str;
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.