]> git.mxchange.org Git - friendica.git/commitdiff
Use filter_var instead of parse_url to validate URLs, since the latter returns true...
authorMatthew Exon <git.mexon@spamgourmet.com>
Thu, 14 Mar 2013 05:58:01 +0000 (13:58 +0800)
committerMatthew Exon <git.mexon@spamgourmet.com>
Thu, 21 Mar 2013 08:27:12 +0000 (16:27 +0800)
include/network.php

index 941ef5e1b9db7482555ae4c07a532c5dd0e1c900..dce092eb95dc775941dfcf6c5c4cfc9d0001c9b1 100644 (file)
@@ -93,8 +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;
-               $url_parsed = @parse_url($newurl);
-               if (isset($url_parsed)) {
+               if (filter_var($newurl, FILTER_VALIDATE_URL)) {
                        $redirects++;
                        return fetch_url($newurl,$binary,$redirects,$timeout);
                }
@@ -188,8 +187,7 @@ function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0)
         $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,false,$redirects,$timeout);
         }