From 51ceffddebac72e76ebb80d9e4dee0ae8479cd0d Mon Sep 17 00:00:00 2001 From: datorik Date: Thu, 3 Sep 2026 13:39:19 +0300 Subject: [PATCH 1/2] Udp.Code. Add ip to white list --- lib/Cleantalk/Common/Helper.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/Cleantalk/Common/Helper.php b/lib/Cleantalk/Common/Helper.php index 79e07925d..06993b4d2 100644 --- a/lib/Cleantalk/Common/Helper.php +++ b/lib/Cleantalk/Common/Helper.php @@ -601,7 +601,23 @@ public static function ipResolve($ip) public static function dnsResolve($host, $out = false) { // Check if the $url is set and it is an url - if ( ! $host || ! filter_var($host, FILTER_VALIDATE_URL)) { + if ( ! $host || ! is_string($host) ) { + return $out; + } + + if ( strpos($host, '://') !== false ) { + $parsed_host = parse_url($host, PHP_URL_HOST); + if ( is_string($parsed_host) && $parsed_host !== '' ) { + $host = $parsed_host; + } + } + + if ( strpos($host, ':') !== false && ! filter_var($host, FILTER_VALIDATE_IP) ) { + $host = strstr($host, ':', true); + } + + if ( ! filter_var($host, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME) + && ! filter_var($host, FILTER_VALIDATE_IP) ) { return $out; } From 047d6a024b562c55ec9c368f84e7470ca5502973 Mon Sep 17 00:00:00 2001 From: Aleksandr Banins Date: Thu, 3 Sep 2026 14:02:23 +0300 Subject: [PATCH 2/2] Update dnsResolve function comment for clarity Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- lib/Cleantalk/Common/Helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cleantalk/Common/Helper.php b/lib/Cleantalk/Common/Helper.php index 06993b4d2..30a0fad5e 100644 --- a/lib/Cleantalk/Common/Helper.php +++ b/lib/Cleantalk/Common/Helper.php @@ -600,7 +600,7 @@ public static function ipResolve($ip) */ public static function dnsResolve($host, $out = false) { - // Check if the $url is set and it is an url + // Validate/normalize host (accept hostname or IP; URLs and host:port are also supported) if ( ! $host || ! is_string($host) ) { return $out; }