From 919005c0f898880ee8c0f5048d84adfcf0ce9a18 Mon Sep 17 00:00:00 2001 From: Alexandros Diamantidis Date: Thu, 17 Sep 2015 13:32:20 +0300 Subject: [PATCH] Fix validateUrlActive() to check host part of URL for correct DNS records validateUrlActive() calls checkdnsrr() which by default looks only for MX records, and passes the whole tail part of the URL after the prefix. It should isolate the host and check for A, AAAA or CNAME DNS records. --- src/Valitron/Validator.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Valitron/Validator.php b/src/Valitron/Validator.php index 098a2f0..d161b8e 100644 --- a/src/Valitron/Validator.php +++ b/src/Valitron/Validator.php @@ -452,9 +452,9 @@ class Validator { foreach ($this->validUrlPrefixes as $prefix) { if (strpos($value, $prefix) !== false) { - $url = str_replace($prefix, '', strtolower($value)); - - return checkdnsrr($url); + $host = parse_url(strtolower($value), PHP_URL_HOST); + + return checkdnsrr($host, 'A') || checkdnsrr($host, 'AAAA') || checkdnsrr($host, 'CNAME'); } }