From 8e151e793f00fece18df26cdbe32557663386146 Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Sun, 16 Apr 2023 19:41:55 +0200 Subject: [PATCH] Closer approximate a fix for the validation of GND IDs --- src/enums/MDNodaRepository.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/enums/MDNodaRepository.php b/src/enums/MDNodaRepository.php index ffa81cd..c295cd1 100644 --- a/src/enums/MDNodaRepository.php +++ b/src/enums/MDNodaRepository.php @@ -277,7 +277,13 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable { $id = strtr($id, $toRemove); } - if (preg_match("/^[0-9-X]*$/", $id) === false) return false; + // There is an issue with this regex + if (preg_match("/^[0-9-X]*$/", $id) === false) { + return false; + } + if (is_numeric(strtr($id, ['-' => '', 'X' => ''])) === false) { + return false; + } return $id; @@ -375,7 +381,7 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable { self::bnf => self::validateNumericId($id, ["https://catalogue.bnf.fr/ark:/12148/cb"]), self::cona => self::validateNumericId($id, ['https://vocab.getty.edu/page/cona/']), self::editionhumboldtdigital => self::validateGndId($id, ['https://edition-humboldt.de/register/personen/detail.xql?normid=http://d-nb.info/gnd/']), - self::gnd => self::validateGndId($id, ['https://d-nb.info/gnd/']), + self::gnd => self::validateGndId($id, ['http://d-nb.info/gnd/', 'https://d-nb.info/gnd/']), self::grobsystematik => self::validateNumericId($id, ['https://term.museum-digital.de/grobsystematik/tag/']), self::iconclass => self::validateIconclassId($id), self::lcsh => self::validateLcshId($id),