Use filter_var instead of parse_url to validate URLs, since the latter returns true even for invalid URLs, in particular the empty string
This commit is contained in:
parent
bb3e8ad785
commit
c7cfc6b170
|
@ -93,8 +93,7 @@ function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_
|
||||||
//$newurl = trim(array_pop($matches));
|
//$newurl = trim(array_pop($matches));
|
||||||
if(strpos($newurl,'/') === 0)
|
if(strpos($newurl,'/') === 0)
|
||||||
$newurl = $url . $newurl;
|
$newurl = $url . $newurl;
|
||||||
$url_parsed = @parse_url($newurl);
|
if (filter_var($newurl, FILTER_VALIDATE_URL)) {
|
||||||
if (isset($url_parsed)) {
|
|
||||||
$redirects++;
|
$redirects++;
|
||||||
return fetch_url($newurl,$binary,$redirects,$timeout);
|
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));
|
$newurl = trim(array_pop($matches));
|
||||||
if(strpos($newurl,'/') === 0)
|
if(strpos($newurl,'/') === 0)
|
||||||
$newurl = $url . $newurl;
|
$newurl = $url . $newurl;
|
||||||
$url_parsed = @parse_url($newurl);
|
if (filter_var($newurl, FILTER_VALIDATE_URL)) {
|
||||||
if (isset($url_parsed)) {
|
|
||||||
$redirects++;
|
$redirects++;
|
||||||
return fetch_url($newurl,false,$redirects,$timeout);
|
return fetch_url($newurl,false,$redirects,$timeout);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue