Re: Net_URL Bug #6470

From: Date: Mon, 20 Feb 2006 09:05:57 +0000
Subject: Re: Net_URL Bug #6470
References: 1 2 3 4 5 6 7  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-41421@lists.php.net to get a copy of this message
A litle complement: bertrand Gugger wrote:
- looks like it treats, or should treat only absolute path, is it ?
It assumes the $this->path starts with a '/', check the constructor.
$this->path        = !empty($HTTP_SERVER_VARS['PHP_SELF']) ?  $HTTP_SERVER_VARS['PHP_SELF'] : '/';
If $HTTP_SERVER_VARS['PHP_SELF'] is set, it will have a '/' in it, I believe.
This is done only if the parameter $url is not some absolute url. The affectation for path is further, and I'm unsure what it does. That looks a little complicated to get that $this->path is empty... and I'm unsure dirname() always return a path starting with a "/" in every situation on all machines. We would need some "guru" here ... lol
This construction is based on parse_url() and is buggy as parse_url() is now able to return false, so the foreach() there is fucked off. [bertrand@ancilla test]$ cat test_parse_url.php <?php $uri = '//example.com/blah.php?url=http://example.com'; $test = parse_url($uri); var_dump($test); [bertrand@ancilla test]$ php test_parse_url.php Content-type: text/html X-Powered-By: PHP/4.3.11 array(2) { ["scheme"]=> string(31) "//example.com/blah.php?url=http" ["host"]=> string(11) "example.com" } [bertrand@ancilla test]$ php5 test_parse_url.php PHP Warning: parse_url(//example.com/blah.php?url=http://example.com) [<a href='function.parse-url'>function.parse-url</a>]: Unable to parse url in /home/bertrand/test/test_parse_url.php on line 3 X-Powered-By: PHP/5.1.2-dev Content-type: text/html <br /> <b>Warning</b>: parse_url(//example.com/blah.php?url=http://example.com) [<a href='function.parse-url'>function.parse-url</a>]: Unable to parse url in <b>/home/bertrand/test/test_parse_url.php</b> on line <b>3</b><br /> bool(false) [bertrand@ancilla test]$ Yes, it belongs to the breaks in BC introduced by php4.4 and php5. But better returning false than wrong parse :) Just parse_url() users have to revide their code, as it's here the case. Ask gurus. Regards -- toggg

« previous php.pear.dev (#41421) next »