From 92319b27f7a40662ba0a901dc69cde60e99e63be Mon Sep 17 00:00:00 2001 From: Hosteroid Date: Tue, 21 Oct 2025 14:51:28 +0300 Subject: [PATCH] Add vCard field validation in WhoisService Added checks to ensure vCard fields are arrays with at least 4 elements before accessing their values. This prevents potential errors when parsing registrar and abuse contact information from RDAP responses. --- app/Services/WhoisService.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/Services/WhoisService.php b/app/Services/WhoisService.php index 6c48fe4..127174c 100644 --- a/app/Services/WhoisService.php +++ b/app/Services/WhoisService.php @@ -392,10 +392,12 @@ class WhoisService // Get registrar name from vCard if (isset($entity['vcardArray'][1])) { foreach ($entity['vcardArray'][1] as $vcardField) { - if ($vcardField[0] === 'fn') { - $info['registrar'] = $vcardField[3]; - } elseif ($vcardField[0] === 'url') { - $info['registrar_url'] = $vcardField[3]; + if (is_array($vcardField) && count($vcardField) >= 4) { + if ($vcardField[0] === 'fn') { + $info['registrar'] = $vcardField[3]; + } elseif ($vcardField[0] === 'url') { + $info['registrar_url'] = $vcardField[3]; + } } } } @@ -406,8 +408,10 @@ class WhoisService if (in_array('abuse', $subEntity['roles'] ?? [])) { if (isset($subEntity['vcardArray'][1])) { foreach ($subEntity['vcardArray'][1] as $vcardField) { - if ($vcardField[0] === 'email') { - $info['abuse_email'] = $vcardField[3]; + if (is_array($vcardField) && count($vcardField) >= 4) { + if ($vcardField[0] === 'email') { + $info['abuse_email'] = $vcardField[3]; + } } } }