]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #654 from mexon/filter_var
authortobiasd <tobias.diekershoff@gmx.net>
Tue, 26 Mar 2013 18:31:11 +0000 (11:31 -0700)
committertobiasd <tobias.diekershoff@gmx.net>
Tue, 26 Mar 2013 18:31:11 +0000 (11:31 -0700)
Use filter_var instead of parse_url to validate URLs, since the latter r...

1  2 
include/network.php

index f6f59fa2d8f26020ca182461c0962edc1fbfd0a9,dce092eb95dc775941dfcf6c5c4cfc9d0001c9b1..e4d01c00fb46ea1a2cc3064a7da72ff809c3a746
@@@ -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);
                }