diff --git a/Classes/Command/BaseCommand.php b/Classes/Command/BaseCommand.php index 59109f0b4..d00ac6808 100644 --- a/Classes/Command/BaseCommand.php +++ b/Classes/Command/BaseCommand.php @@ -339,7 +339,26 @@ private function addCollections(Document &$document, array $collections): void $documentCollection = GeneralUtility::makeInstance(Collection::class); $documentCollection->setIndexName($collection); $documentCollection->setLabel($collection); - $documentCollection->setOaiName((!empty($this->extConf['general']['publishNewCollections']) ? Helper::getCleanString($collection) : '')); + $setSpec = ''; + if (!empty($this->extConf['general']['publishNewCollections'])) { + // setSpec only allows unreserved characters (rfc2396). + // alnum | "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")" + // Here we are a little bit more restrictive because + // some more unreserved characters are not allowed. + // Convert whitespaces to dash. + $setSpec = $collection; + $setSpec = preg_replace('/[\s]/', '-', $setSpec); + // Remove multiple dashes. + $setSpec = preg_replace('/[-]{2,}/', '-', $setSpec); + // Remove undesired characters. + $setSpec = preg_replace('/[^\w:-]/', '', $setSpec); + // A hierarchical setSpec consists of two or more + // normal setSpec which are separated by colons. + // Remove colons which don't separate hierarchical setSpec entries. + $setSpec = trim($setSpec, ':'); + $setSpec = preg_replace('/:{2,}/', ':', $setSpec); + } + $documentCollection->setOaiName($setSpec); $documentCollection->setIndexSearch(''); $documentCollection->setDescription(''); // add to CollectionRepository diff --git a/Configuration/TCA/tx_dlf_collections.php b/Configuration/TCA/tx_dlf_collections.php index 3b7814eb7..415870ac3 100644 --- a/Configuration/TCA/tx_dlf_collections.php +++ b/Configuration/TCA/tx_dlf_collections.php @@ -137,7 +137,8 @@ 'type' => 'input', 'size' => 30, 'max' => 255, - 'eval' => 'nospace,alphanum_x,uniqueInPid', + // TODO: Add own form evaluation (see OAI-PMH setSpec). + 'eval' => 'nospace,uniqueInPid', 'default' => '', ], ],