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.
This commit is contained in:
@@ -392,6 +392,7 @@ class WhoisService
|
|||||||
// Get registrar name from vCard
|
// Get registrar name from vCard
|
||||||
if (isset($entity['vcardArray'][1])) {
|
if (isset($entity['vcardArray'][1])) {
|
||||||
foreach ($entity['vcardArray'][1] as $vcardField) {
|
foreach ($entity['vcardArray'][1] as $vcardField) {
|
||||||
|
if (is_array($vcardField) && count($vcardField) >= 4) {
|
||||||
if ($vcardField[0] === 'fn') {
|
if ($vcardField[0] === 'fn') {
|
||||||
$info['registrar'] = $vcardField[3];
|
$info['registrar'] = $vcardField[3];
|
||||||
} elseif ($vcardField[0] === 'url') {
|
} elseif ($vcardField[0] === 'url') {
|
||||||
@@ -399,6 +400,7 @@ class WhoisService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check for abuse contact in nested entities
|
// Check for abuse contact in nested entities
|
||||||
if (isset($entity['entities']) && is_array($entity['entities'])) {
|
if (isset($entity['entities']) && is_array($entity['entities'])) {
|
||||||
@@ -406,6 +408,7 @@ class WhoisService
|
|||||||
if (in_array('abuse', $subEntity['roles'] ?? [])) {
|
if (in_array('abuse', $subEntity['roles'] ?? [])) {
|
||||||
if (isset($subEntity['vcardArray'][1])) {
|
if (isset($subEntity['vcardArray'][1])) {
|
||||||
foreach ($subEntity['vcardArray'][1] as $vcardField) {
|
foreach ($subEntity['vcardArray'][1] as $vcardField) {
|
||||||
|
if (is_array($vcardField) && count($vcardField) >= 4) {
|
||||||
if ($vcardField[0] === 'email') {
|
if ($vcardField[0] === 'email') {
|
||||||
$info['abuse_email'] = $vcardField[3];
|
$info['abuse_email'] = $vcardField[3];
|
||||||
}
|
}
|
||||||
@@ -417,6 +420,7 @@ class WhoisService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Parse nameservers
|
// Parse nameservers
|
||||||
if (isset($rdapData['nameservers']) && is_array($rdapData['nameservers'])) {
|
if (isset($rdapData['nameservers']) && is_array($rdapData['nameservers'])) {
|
||||||
|
|||||||
Reference in New Issue
Block a user