Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.2.0

Bug #19176 resolve() does not merge the path if the base path is empty
Submitted: 2011-12-31 07:07 UTC
From: wellnamed Assigned: tkli
Status: Closed Package: Net_URL2 (version 2.0.0)
PHP Version: 5.2.12 OS: Linux
Roadmaps: (Not assigned)    

 [2011-12-31 07:07 UTC] wellnamed (Matthew Kauffman)
Description: ------------ If you define a Net_URL2 instance that looks like "" and then output $foo->resolve('bar.html')->getUrl() The resulting url is "" 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(""); $test = $foo->resolve('test.html')->getURL(); print $test; Expected result: ---------------- Actual result: --------------


 [2011-12-31 07:16 UTC] wellnamed (Matthew Kauffman)
-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
 [2012-03-04 09:40 UTC] tkli (Tom Klingenberg)
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) {
 [2013-04-19 12:38 UTC] tkli (Tom Klingenberg)
Please close this ticket. The issue has been resolved in the Fork of this package and it will be merged when this package moves to Github.
 [2013-04-26 02:18 UTC] tkli (Tom Klingenberg)
Fix committed in bf991bc182855cc1a3451a5e99bb22d7875ff130 (pear:master) 3 days ago.
 [2013-12-25 06:27 UTC] tkli (Tom Klingenberg)
-Status: Open +Status: Closed -Assigned To: +Assigned To: tkli
Fixed in 2.0.1