Welcome Guest, Not a member yet? Register   Sign In
codeigniter 1.7 on PHP5.3
#1

[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!
#2

[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!
#3

[eluser]nikkofu[/eluser]
the problem resolved!

here is my configs:

$config['permitted_uri_chars'] ='a-z 0-9~%.:_-u4e00-u9fa5';


&lt;?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
#4

[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'))
So the if should be like this:
Code:
if ( ! preg_match(”|^[”.$this->config->item(‘permitted_uri_chars’).”]+$|i”, $str))
// or
if ( ! preg_match(”|^[”.str_replace('\\-', '-', preg_quote($this->config->item(‘permitted_uri_chars’))).”]+$|i”, $str))
#5

[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\
// Lines from 127 to 137

if ($is_subclass == TRUE)
{
    $name = config_item('subclass_prefix').$class;
    $objects[$class] =& new $name(); // line 130
    return $objects[$class];
}

$name = ($class != 'Controller') ? 'CI_'.$class : $class;

$objects[$class] =& new $name(); // line 136
return $objects[$class];

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.
#6

[eluser]nikkofu[/eluser]
just move back to PHP5.2.10, and the project works again.

PHP5.3 sucks too much.
#7

[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
#8

[eluser]Unknown[/eluser]
I think there are a lot of work to do with 5.3.0 support.
#9

[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]
#10

[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




Theme © iAndrew 2016 - Forum software by © MyBB