From 3dd4169b5f25252bdec2037867c11814286afb75 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 21 Sep 2020 20:35:24 +0300 Subject: clarify some URL validation-related error messages --- classes/rssutils.php | 3 ++- include/functions.php | 11 ++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/classes/rssutils.php b/classes/rssutils.php index e730e516a..7cfbca6d3 100755 --- a/classes/rssutils.php +++ b/classes/rssutils.php @@ -411,9 +411,10 @@ class RSSUtils { $feed_data = trim($feed_data); global $fetch_effective_url; + global $fetch_effective_ip_addr; Debug::log("fetch done.", Debug::$LOG_VERBOSE); - Debug::log("effective URL (after redirects): " . clean($fetch_effective_url), Debug::$LOG_VERBOSE); + Debug::log("effective URL (after redirects): " . clean($fetch_effective_url) . " (IP: $fetch_effective_ip_addr)", Debug::$LOG_VERBOSE); Debug::log("source last modified: " . $fetch_last_modified, Debug::$LOG_VERBOSE); if ($feed_data && $fetch_last_modified != $stored_last_modified) { diff --git a/include/functions.php b/include/functions.php index e8d5ebad0..c6344f778 100644 --- a/include/functions.php +++ b/include/functions.php @@ -184,6 +184,7 @@ global $fetch_last_content_type; global $fetch_last_modified; global $fetch_effective_url; + global $fetch_effective_ip_addr; global $fetch_curl_used; global $fetch_domain_hits; @@ -194,6 +195,7 @@ $fetch_curl_used = false; $fetch_last_modified = ""; $fetch_effective_url = ""; + $fetch_effective_ip_addr = ""; if (!is_array($fetch_domain_hits)) $fetch_domain_hits = []; @@ -240,7 +242,10 @@ $url = validate_url($url, true); - if (!$url) return false; + if (!$url) { + $fetch_last_error = "Requested URL failed to validate."; + return false; + } $url_host = parse_url($url, PHP_URL_HOST); $ip_addr = gethostbyname($url_host); @@ -351,7 +356,7 @@ $fetch_effective_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); if (!validate_url($fetch_effective_url, true)) { - $fetch_last_error = "URL hostname received after redirection failed to validate."; + $fetch_last_error = "URL received after redirection failed extended validation."; return false; } @@ -444,7 +449,7 @@ $fetch_effective_url = resolve_redirects($url, $timeout ? $timeout : FILE_FETCH_CONNECT_TIMEOUT); if (!validate_url($fetch_effective_url, true)) { - $fetch_last_error = "URL hostname received after redirection failed to validate."; + $fetch_last_error = "URL received after redirection failed extended validation."; return false; } -- cgit v1.2.3