Re: Bug #19176 [Com]: resolve() does not merge the path if the base path is empty

From: Date: Sun, 04 Mar 2012 07:00:05 +0000
Subject: Re: Bug #19176 [Com]: resolve() does not merge the path if the base path is empty
References: 1  Groups: php.pear.qa 
Request: Send a blank email to pear-qa+get-6036@lists.php.net to get a copy of this message
iPhone On Mar 4, 2012, at 12:40, "tklingenberg@lastflood.com" <pear-qa@lists.php.net> wrote: > Edit report at > https://pear.php.net/bugs/bug.php?id=19176&edit=1 > > ID: 19176 > Comment by: tklingenberg@lastflood.com > Reported By: mkauffman at rightnow dot com > Summary: resolve() does not merge the path if the base path is > empty > Status: Open > Type: Bug > Package: Net_URL2 > Operating System: Linux > Package Version: 2.0.0 > PHP Version: 5.2.12 > Roadmap Versions: > New Comment: > > I could reproduce the problem but came to another conclusion using a > step debugger. > > The "5.2.3. Merge Paths" subroutine is broken. Per RFC: > > If the base URI has a defined authority component and an empty > path, then return a string consisting of "/" concatenated with > the > reference's path; > > Net_URL2 did not took the reference path but the base path. I could fix > it with the following patch: > > > Index: Net/URL2.php > =================================================================== > --- Net/URL2.php (revision 323857) > +++ Net/URL2.php (revision ) > @@ -720,7 +720,7 @@ > } else { > // Merge paths (RFC 3986, section 5.2.3) > if ($this->_host !== false && $this->_path == > '') { > - $target->_path = '/' . $this->_path; > + $target->_path = '/' . $reference->_path; > } else { > $i = strrpos($this->_path, '/'); > if ($i !== false) { > > > Previous Comments: > ------------------------------------------------------------------------ > > [2011-12-31 02:16:08] wellnamed > > -Summary: resolve() does not merge the path if the base url is > empty > +Summary: resolve() does not merge the path if the base path is > empty > Fixed the summary to reference base path > > ------------------------------------------------------------------------ > > [2011-12-31 02:07:54] wellnamed > > Description: > ------------ > If you define a Net_URL2 instance that looks like > "http://www.foo.com" > > and then output $foo->resolve('bar.html')->getUrl() > > The resulting url is "http://www.foo.com/" > > It appears to me that the issue is at line 729 in URL2.php. The line > > $target->_path .= $reference->_path; > > should be outside of the else statement so that it appends the reference > path in both cases. This seems to fix at least this case, although I > confess I haven't done enough testing and am not familiar enough with > this code to be sure that it's entirely correct. > > Test script: > --------------- > $foo = new new Net_URL2("http://www.foo.com"); > $test = $foo->resolve('test.html')->getURL(); > > print $test; > > Expected result: > ---------------- > http://www.foo.com/test.html > > Actual result: > -------------- > http://www.foo.com/ > > ------------------------------------------------------------------------ > > > -- > Edit this bug report at > https://pear.php.net/bugs/bug.php?id=19176&edit=1 > > > -- > PEAR Bugs Mailing List (http://pear.php.net/bugs/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.pear.qa (#6036) next »