diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/functions.php | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/include/functions.php b/include/functions.php index 565a8fd41..122e86b3e 100644 --- a/include/functions.php +++ b/include/functions.php @@ -246,7 +246,7 @@ $ip_addr = gethostbyname($url_host); if (!$ip_addr || strpos($ip_addr, "127.") === 0) { - $fetch_last_error = "URL hostname failed to resolve or resolved to loopback address ($ip_addr)"; + $fetch_last_error = "URL hostname failed to resolve or resolved to a loopback address ($ip_addr)"; return false; } @@ -350,6 +350,20 @@ $fetch_effective_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); + if (!validate_url($fetch_effective_url)) { + $fetch_last_error = "URL hostname received after redirection failed to validate."; + + return false; + } + + $fetch_effective_ip_addr = gethostbyname(parse_url($fetch_effective_url, PHP_URL_HOST)); + + if (!$fetch_effective_ip_addr || strpos($fetch_effective_ip_addr, "127.") === 0) { + $fetch_last_error = "URL hostname received after redirection failed to resolve or resolved to a loopback address ($fetch_effective_ip_addr)"; + + return false; + } + $fetch_last_error_code = $http_code; if ($http_code != 200 || $type && strpos($fetch_last_content_type, "$type") === false) { |