From eb9bd03ef86e0c453aa034fc9b33dcde278056fc Mon Sep 17 00:00:00 2001 From: Matthew Exon Date: Mon, 29 Jul 2013 10:11:08 +0800 Subject: [PATCH] If the header returns an absolute path as a redirect, don't simply append the path to the old URL, remove the old absolute path first. For example, original URL: http://www.theregister.co.uk/2013/07/28/birmingham_uni_car_cracker_muzzled_by_lords/print.html Redirect from header: /Print/2013/07/28/birmingham_uni_car_cracker_muzzled_by_lords/ Incorrect result: http://www.theregister.co.uk/2013/07/28/birmingham_uni_car_cracker_muzzled_by_lords/print.html/Print/2013/07/28/birmingham_uni_car_cracker_muzzled_by_lords/ Correct result after this patch: http://www.theregister.co.uk/Print/2013/07/28/birmingham_uni_car_cracker_muzzled_by_lords/ --- include/network.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/network.php b/include/network.php index d2732e0393..d398d8fa0c 100644 --- a/include/network.php +++ b/include/network.php @@ -93,7 +93,7 @@ function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_ $newurl = trim(array_pop($matches)); } if(strpos($newurl,'/') === 0) - $newurl = $url . $newurl; + $newurl = $old_location_info["scheme"]."://".$old_location_info["host"].$newurl; if (filter_var($newurl, FILTER_VALIDATE_URL)) { $redirects++; return fetch_url($newurl,$binary,$redirects,$timeout);