Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion lib/Cleantalk/Common/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment thread
Copilot marked this conversation as resolved.
Outdated
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;
}
Comment thread
alexander-b-clean marked this conversation as resolved.

Expand Down
Loading