From 7e79b9c3a9efb9220205d4002a873a649c378f71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Gangloff?= Date: Sat, 13 Sep 2025 01:56:05 +0200 Subject: [PATCH] fix: some registries create IANA identifiers and return them in the RDAP response... --- src/Service/RDAPService.php | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/Service/RDAPService.php b/src/Service/RDAPService.php index 3f26eb3..a1a3bf8 100644 --- a/src/Service/RDAPService.php +++ b/src/Service/RDAPService.php @@ -35,7 +35,6 @@ use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\HttpClient\Exception\ClientException; use Symfony\Component\HttpFoundation\Exception\BadRequestException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; -use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException; use Symfony\Component\Yaml\Yaml; use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface; @@ -519,6 +518,8 @@ class RDAPService */ private function registerEntity(array $rdapEntity, array $roles, string $domain, Tld $tld): Entity { + $entity = null; + /** * If the RDAP server transmits the entity's IANA number, it is used as a priority to identify the entity. * @@ -528,9 +529,16 @@ class RDAPService if (isset($rdapEntity['publicIds'])) { foreach ($rdapEntity['publicIds'] as $publicId) { if ('IANA Registrar ID' === $publicId['type'] && isset($publicId['identifier']) && '' !== $publicId['identifier']) { - $rdapEntity['handle'] = $publicId['identifier']; - $isIANAid = true; - break; + $entity = $this->entityRepository->findOneBy([ + 'handle' => $rdapEntity['handle'], + 'tld' => null, + ]); + + if (null !== $entity) { + $rdapEntity['handle'] = $publicId['identifier']; + $isIANAid = true; + break; + } } } } @@ -547,19 +555,17 @@ class RDAPService ]); } - $entity = $this->entityRepository->findOneBy([ - 'handle' => $rdapEntity['handle'], - 'tld' => $isIANAid ? null : $tld, - ]); + if (null === $entity) { + $entity = $this->entityRepository->findOneBy([ + 'handle' => $rdapEntity['handle'], + 'tld' => $tld, + ]); + } if ($isIANAid && null !== $entity) { return $entity; } - if ($isIANAid && null === $entity) { - throw new ServiceUnavailableHttpException('The server does not know the IANA identifier of this registrar ('.$rdapEntity['handle'].')'); - } - if (null === $entity) { $entity = (new Entity())->setTld($tld);