codeigniter 1.7 on PHP5.3 |
[eluser]nikkofu[/eluser]
recently i upgraded the PHP to version 5.3, and the website occurs some errors: "The URI you submitted has disallowed characters." please help! thanks!
[eluser]nikkofu[/eluser]
and this is MY_URI.php, it works fine at PHP5.2.3-5 <?php class MY_URI extends CI_URI { function _filter_uri($str) { if ($str != '' AND $this->config->item('permitted_uri_chars') != '') { //echo $str . '<br>';//here is my debug code $str = urlencode($str); if ( ! preg_match("|^[".preg_quote($this->config->item('permitted_uri_chars'))."]+$|i", $str)) { exit('The URI you submitted has disallowed characters.'); } $str = urldecode($str); } return $str; } } when i goes to http://domain/welcome/index with PHP5.2.3-5, the original debug line shows: welcome<br>index<br> and i goes to http://domain/welcom/index again in PHP5.3.0, the new debug line shows: welcome<br> it breaks the URI and lost the "index" please help! thanks again!
[eluser]nikkofu[/eluser]
the problem resolved! here is my configs: $config['permitted_uri_chars'] ='a-z 0-9~%.:_-u4e00-u9fa5'; <?php class MY_URI extends CI_URI { function _filter_uri($str) { if ($str != '' AND $this->config->item('permitted_uri_chars') != '') { //echo $str . '<br>'; $str = urlencode($str); //echo preg_quote($this->config->item('permitted_uri_chars')) . '<br>'; /* if ( ! preg_match("|^[".preg_quote($this->config->item('permitted_uri_chars'))."]+$|i", $str)) { exit('The URI you submitted has disallowed characters.'); } */ if ( ! preg_match("|^[a-z 0-9~%\.\:_-u4e00-u9fa5]+$|i", $str)) { exit('The URI you submitted has disallowed characters.'); } $str = urldecode($str); } return $str; } } and here //echo preg_quote($this->config->item('permitted_uri_chars')) . '<br>'; shows different with PHP5.2.3-5 so i put the right string here if ( ! preg_match("|^[a-z 0-9~%\.\:_-u4e00-u9fa5]+$|i", $str)) i dont know the reason and i'm a php beginner, i just make it with the string with the original echoed in php5.2.3-5 migration is not funny! :S
[eluser]m4rw3r[/eluser]
The reason is that preg_quote() quotes the dash ("-") character in PHP 5.3, which means that you should either remove the call to preg_quote(), or to replace it with something like this: Code: str_replace('\\-', '-', preg_quote($this->config->item('permitted_uri_chars')) Code: if ( ! preg_match(”|^[”.$this->config->item(‘permitted_uri_chars’).”]+$|i”, $str))
[eluser]Gustav[/eluser]
More errors when migrating from PHP v5.2.3 to v5.3.0: Deprecated: Assigning the return value of new by reference is deprecated in system\codeigniter\Common.php on line 130 Deprecated: Assigning the return value of new by reference is deprecated in system\codeigniter\Common.php on line 136 Code: // File Common.php in system\codeigniter\ And not only in that file. v5.3.0 is big problem for CI 1.7.1 because all my CI projects throw errors. CI needs an update.
[eluser]nikkofu[/eluser]
just move back to PHP5.2.10, and the project works again. PHP5.3 sucks too much.
[eluser]GSV Sleeper Service[/eluser]
[quote author="nikkofu" date="1247154570"]just move back to PHP5.2.10, and the project works again. PHP5.3 sucks too much.[/quote] er, namespaces, lambda functions/closures, improved garbage collection etc. you sir, are speaking out of your anus
[eluser]Unknown[/eluser]
I think there are a lot of work to do with 5.3.0 support.
[eluser]Gustav[/eluser]
I tested 5.3 in my testmachine and yes, I changed back to 5.2.3. Luckily my webhost allows to choose between PHP versions so no problem there when they make v5.3 available (which is soon). But still -- CI needs an update. v5.3 is big update for PHP and I would like to use it. [quote author="nikkofu" date="1247154570"]just move back to PHP5.2.10, and the project works again. PHP5.3 sucks too much.[/quote]
[eluser]Dam1an[/eluser]
[quote author="Gustav" date="1247160124"]But still -- CI needs an update. v5.3 is big update for PHP and I would like to use it.[/quote] Good luck getting them to move to 5.3 any time soon, as PHP4 support looks like it will be around for a while |
Welcome Guest, Not a member yet? Register Sign In |