Added additional variants of nomisma, iconclass IDs
This commit is contained in:
@@ -400,12 +400,23 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
|
||||
private static function validateIconclassId(string $id):string|false {
|
||||
|
||||
if (filter_var($id, FILTER_VALIDATE_URL) !== false) {
|
||||
$id = strtr($id, ['http://iconclass.org/rkd/' => '', 'http://iconclass.org/' => '', 'https://iconclass.org/' => '']);
|
||||
$id = rtrim(strtr($id, [
|
||||
'http://iconclass.org/rkd/' => '',
|
||||
'http://iconclass.org/' => '',
|
||||
'https://iconclass.org/' => '',
|
||||
'http://www.iconclass.org/rkd/' => '',
|
||||
'http://www.iconclass.org/' => '',
|
||||
'https://www.iconclass.org/' => '',
|
||||
]), '/');
|
||||
}
|
||||
$id = trim($id, "/");
|
||||
|
||||
if (!empty(trim($id, '0123456789abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ'))) {
|
||||
return false;
|
||||
if (!empty(trim($id, '0123456789abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ(+)'))) {
|
||||
// Try url_decoding
|
||||
$id = urldecode($id);
|
||||
if (!empty(trim($id, '0123456789abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ(+)'))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return $id;
|
||||
@@ -632,6 +643,29 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates an nomisma ID, returning a string or false.
|
||||
*
|
||||
* @param string $id ID to validate.
|
||||
*
|
||||
* @return string|false
|
||||
*/
|
||||
private static function validateNomismaId(string $id):string|false {
|
||||
|
||||
$id = strtr($id, [
|
||||
"http://nomisma.org/id/" => '',
|
||||
"https://nomisma.org/id/" => '',
|
||||
]);
|
||||
|
||||
// Ensure the remaining string does not contain spaces or slashes
|
||||
foreach (['/', ' '] as $disallowedChar) {
|
||||
if (str_contains($id, $disallowedChar)) return false;
|
||||
}
|
||||
|
||||
return $id;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates an NPG ID, returning a string or false.
|
||||
*
|
||||
@@ -761,7 +795,7 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
|
||||
]),
|
||||
self::ndp_ikmk => self::validateNdpIkmkForPlaces($id),
|
||||
self::ndp_ikmk_persons => self::validateNumericId($id, ['https://ikmk.smb.museum/ndp/person/']),
|
||||
self::nomisma => self::validateNumericId($id, ['http://nomisma.org/id/']),
|
||||
self::nomisma => self::validateNomismaId($id),
|
||||
self::npg => self::validateNpgId($id),
|
||||
self::oberbegriffsdatei => self::validateNumericId($id, ['https://term.museum-digital.de/oberbegriffsdatei/tag/']),
|
||||
self::orcid => self::validateOrcidId($id),
|
||||
|
||||
Reference in New Issue
Block a user