diff --git a/src/lib/Repository/NameSchema/SchemaIdentifierExtractor.php b/src/lib/Repository/NameSchema/SchemaIdentifierExtractor.php index 803c6c814d..cb7d76c51f 100644 --- a/src/lib/Repository/NameSchema/SchemaIdentifierExtractor.php +++ b/src/lib/Repository/NameSchema/SchemaIdentifierExtractor.php @@ -27,7 +27,7 @@ final class SchemaIdentifierExtractor implements SchemaIdentifierExtractorInterf */ public function extract(string $schemaString): array { - $allTokens = '/<([^>]+)>/'; + $allTokens = '/<([^>-]+)>/'; if (false === preg_match_all($allTokens, $schemaString, $matches)) { return []; @@ -36,7 +36,6 @@ public function extract(string $schemaString): array $strategyIdentifiers = []; foreach ($matches[1] as $tokenExpression) { $tokens = explode('|', $tokenExpression); - foreach ($tokens as $token) { $strategyToken = explode(':', $token, 2); @@ -47,8 +46,11 @@ public function extract(string $schemaString): array $strategy = 'field'; } + $token = preg_replace('/[()<>\[\]]/', '', $token); $strategyIdentifiers[$strategy][] = $token; } + + $strategyIdentifiers[$strategy] = array_unique($strategyIdentifiers[$strategy]); } return $strategyIdentifiers; diff --git a/tests/lib/Repository/NameSchema/SchemaIdentifierExtractorTest.php b/tests/lib/Repository/NameSchema/SchemaIdentifierExtractorTest.php index 76a4d2dc97..bf60625f60 100644 --- a/tests/lib/Repository/NameSchema/SchemaIdentifierExtractorTest.php +++ b/tests/lib/Repository/NameSchema/SchemaIdentifierExtractorTest.php @@ -67,6 +67,15 @@ public function getDataForTestExtract(): iterable 'field' => ['bar', 'baz'], ], ]; + + $schemaString = ' )--'; + yield $schemaString => [ + $schemaString, + [ + 'field' => ['specification', 'name', 'image1', 'baz', 'bar'], + 'custom' => ['bar'], + ], + ]; } protected function setUp(): void