From d7708f6fb6776baec69edd1669cc3f910ce9a562 Mon Sep 17 00:00:00 2001 From: Pinga Date: Wed, 2 Jul 2025 12:58:52 +0300 Subject: [PATCH] Identica extension fixes --- docs/epp.md | 4 ++-- epp/src/EppWriter.php | 2 +- epp/src/epp-create.php | 8 ++++---- epp/src/epp-update.php | 30 +++++++++--------------------- epp/start_epp.php | 1 + 5 files changed, 17 insertions(+), 28 deletions(-) diff --git a/docs/epp.md b/docs/epp.md index 4b9694e..e1e072b 100644 --- a/docs/epp.md +++ b/docs/epp.md @@ -472,7 +472,7 @@ Each command section below includes real-world XML request and response samples xsi:schemaLocation="https://namingo.org/epp/identica-1.0 identica-1.0.xsd"> 1234567890 2 - 2025-07-02T10:34:00.000Z + 2025-07-02 10:34:00.000 admin42|api|Validated via national ID system @@ -556,7 +556,7 @@ Each command section below includes real-world XML request and response samples xsi:schemaLocation="https://namingo.org/epp/identica-1.0 identica-1.0.xsd"> 1234567890 2 - 2025-07-02T10:34:00.000Z + 2025-07-02 10:34:00.000 admin42|api|Validated via national ID system diff --git a/epp/src/EppWriter.php b/epp/src/EppWriter.php index 9da5a09..96debd0 100644 --- a/epp/src/EppWriter.php +++ b/epp/src/EppWriter.php @@ -620,7 +620,7 @@ class EppWriter { // Validation timestamp if (!empty($resp['validation_stamp'])) { $stamp = new \DateTime($resp['validation_stamp']); - $writer->writeElement('identica:date', $stamp->format('Y-m-d\TH:i:s.v\Z')); + $writer->writeElement('identica:date', $stamp->format('Y-m-d H:i:s.v')); } // Validation log diff --git a/epp/src/epp-create.php b/epp/src/epp-create.php index d050642..c746ad3 100644 --- a/epp/src/epp-create.php +++ b/epp/src/epp-create.php @@ -328,11 +328,11 @@ function processContactCreate($conn, $db, $xml, $clid, $database_type, $trans) { } } - $obj_ext = $xml->xpath('//identica:create')[0] ?? null; + $identicaCreate = $xml->xpath('//identica:create') ?? null; - if ($obj_ext) { - $nin = (string)$obj_ext->xpath('identica:nin')[0] ?? ''; - $nin_type = (string)$obj_ext->xpath('identica:nin/@type')[0] ?? ''; + if ($identicaCreate) { + $nin = (string) ($xml->xpath('//identica:nin[1]')[0] ?? null); + $nin_type = (string) ($xml->xpath('//identica:nin/@type[1]')[0] ?? null); if (!preg_match('/\d/', $nin)) { sendEppError($conn, $db, 2005, 'NIN should contain one or more numbers', $clTRID, $trans); diff --git a/epp/src/epp-update.php b/epp/src/epp-update.php index a2435c1..10cdc85 100644 --- a/epp/src/epp-update.php +++ b/epp/src/epp-update.php @@ -420,24 +420,12 @@ function processContactUpdate($conn, $db, $xml, $clid, $database_type, $trans) { } - $identicaUpdateResults = $xml->xpath('//identica:update'); - - if (!empty($identicaUpdateResults)) { - $identica_update = $identicaUpdateResults[0]; - } else { - $identica_update = null; - } - - if ($identica_update) { - $nin = (string)$identica_update->xpath('//identica:nin[1]')[0]; - $nin_type = (string)$identica_update->xpath('//identica:nin/@type[1]')[0]; - $status = $identica_update->xpath('//identica:status[1]'); - $statusDate = $identica_update->xpath('//identica:date[1]'); - $statusDetails = $identica_update->xpath('//identica:details[1]'); - - $validation = isset($status[0]) ? (string)$status[0] : null; - $validation_stamp = isset($statusDate[0]) ? (string)$statusDate[0] : null; - $validation_log = isset($statusDetails[0]) ? (string)$statusDetails[0] : null; + if (isset($identicaUpdate)) { + $nin = (string) ($xml->xpath('//identica:nin[1]')[0] ?? null); + $nin_type = (string) ($xml->xpath('//identica:nin/@type[1]')[0] ?? null); + $validation = (string) ($xml->xpath('//identica:status[1]')[0] ?? null); + $validation_stamp = (string) ($xml->xpath('//identica:date[1]')[0] ?? null); + $validation_log = (string) ($xml->xpath('//identica:details[1]')[0] ?? null); if (!preg_match('/\d/', $nin)) { sendEppError($conn, $db, 2005, 'NIN should contain one or more numbers', $clTRID, $trans); @@ -454,8 +442,8 @@ function processContactUpdate($conn, $db, $xml, $clid, $database_type, $trans) { return; } - if ($validation_stamp !== null && !preg_match('/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/', $validation_stamp)) { - sendEppError($conn, $db, 2005, 'Invalid status date format. Use ISO 8601 format like 2025-07-02T12:00:00.000Z', $clTRID, $trans); + if ($validation_stamp !== null && \DateTime::createFromFormat('Y-m-d H:i:s.u', $validation_stamp) === false) { + sendEppError($conn, $db, 2005, 'Validation date must be in format Y-m-d H:i:s.v (e.g. 2025-07-02 10:34:00.000)', $clTRID, $trans); return; } @@ -724,7 +712,7 @@ function processContactUpdate($conn, $db, $xml, $clid, $database_type, $trans) { } - if ($identica_update) { + if ($identicaUpdate) { $query = " UPDATE contact SET nin = ?, nin_type = ?, validation = ?, validation_stamp = ?, validation_log = ?, upid = ?, lastupdate = CURRENT_TIMESTAMP(3) diff --git a/epp/start_epp.php b/epp/start_epp.php index 0c71d61..8acef1b 100644 --- a/epp/start_epp.php +++ b/epp/start_epp.php @@ -200,6 +200,7 @@ $server->handle(function (Connection $conn) use ($table, $eppExtensionsTable, $p $xml->registerXPathNamespace('mark', 'urn:ietf:params:xml:ns:mark-1.0'); $xml->registerXPathNamespace('allocationToken', 'urn:ietf:params:xml:ns:allocationToken-1.0'); $xml->registerXPathNamespace('loginSec', 'urn:ietf:params:xml:ns:epp:loginSec-1.0'); + $xml->registerXPathNamespace('identica', 'https://namingo.org/epp/identica-1.0'); if ($xml->getName() != 'epp') { sendEppError($conn, $pdo, 2001, 'Root element must be ');