]> git.mxchange.org Git - friendica.git/commitdiff
If the header returns an absolute path as a redirect, don't simply append the path...
authorMatthew Exon <git.mexon@spamgourmet.com>
Mon, 29 Jul 2013 02:11:08 +0000 (10:11 +0800)
committerMatthew Exon <git.mexon@spamgourmet.com>
Mon, 29 Jul 2013 02:15:39 +0000 (10:15 +0800)
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

index d2732e0393796f9bd9abe80b22bfae347b5ec6c8..d398d8fa0c2a643b69172473aa865d3969bc6308 100644 (file)
@@ -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);