From: tobiasd Date: Tue, 26 Mar 2013 18:31:11 +0000 (-0700) Subject: Merge pull request #654 from mexon/filter_var X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e7c705c9a18864aa1eea4856f58303c043c44d04;p=friendica.git Merge pull request #654 from mexon/filter_var Use filter_var instead of parse_url to validate URLs, since the latter r... --- e7c705c9a18864aa1eea4856f58303c043c44d04 diff --cc include/network.php index f6f59fa2d8,dce092eb95..e4d01c00fb --- a/include/network.php +++ b/include/network.php @@@ -88,14 -88,12 +88,13 @@@ function fetch_url($url,$binary = false if (($new_location_info["path"] == "") AND ($new_location_info["host"] != "")) $newurl = $new_location_info["scheme"]."://".$new_location_info["host"].$old_location_info["path"]; - //$matches = array(); - //preg_match('/(Location:|URI:)(.*?)\n/', $header, $matches); - //$newurl = trim(array_pop($matches)); + $matches = array(); + if (preg_match('/(Location:|URI:)(.*?)\n/', $header, $matches)) { + $newurl = trim(array_pop($matches)); + } if(strpos($newurl,'/') === 0) $newurl = $url . $newurl; - $url_parsed = @parse_url($newurl); - if (isset($url_parsed)) { + if (filter_var($newurl, FILTER_VALIDATE_URL)) { $redirects++; return fetch_url($newurl,$binary,$redirects,$timeout); }