diff --git a/src/Symfony/Component/Validator/Mapping/Cache/Psr6Cache.php b/src/Symfony/Component/Validator/Mapping/Cache/Psr6Cache.php index c0266e65a5..7d1cdd8003 100644 --- a/src/Symfony/Component/Validator/Mapping/Cache/Psr6Cache.php +++ b/src/Symfony/Component/Validator/Mapping/Cache/Psr6Cache.php @@ -66,6 +66,11 @@ class Psr6Cache implements CacheInterface */ private function escapeClassName(string $class): string { + if (false !== strpos($class, '@')) { + // anonymous class: replace all PSR6-reserved characters + return str_replace(["\0", '\\', '/', '@', ':', '{', '}', '(', ')'], '.', $class); + } + return str_replace('\\', '.', $class); } } diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.cs.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.cs.xlf index 4b966698f7..e637d09aa9 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.cs.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.cs.xlf @@ -318,6 +318,22 @@ Error Chyba + + This is not a valid UUID. + Tato hodnota není platné UUID. + + + This value should be a multiple of {{ compared_value }}. + Tato hodnota musí být násobek hodnoty {{ compared_value }}. + + + This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}. + Bankovní identifikační kód (BIC) neodpovídá mezinárodnímu číslu účtu (IBAN) {{ iban }}. + + + This value should be valid JSON. + Tato hodnota musí být validní JSON. + diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Cache/Psr6CacheTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Cache/Psr6CacheTest.php index c11dddbf6f..fcac5e232a 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Cache/Psr6CacheTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Cache/Psr6CacheTest.php @@ -23,4 +23,12 @@ class Psr6CacheTest extends AbstractCacheTest $this->cache->write($metadata); $this->assertFalse($this->cache->has('Foo_Bar')); } + + public function testNameWithInvalidChars() + { + $metadata = new ClassMetadata('class@anonymous/path/file'); + + $this->cache->write($metadata); + $this->assertTrue($this->cache->has('class@anonymous/path/file')); + } }