8000 [PropertyAccessor] fix encoding of cache keys · symfony/symfony@a22ae3c · GitHub
[go: up one dir, main page]

Skip to content

Commit a22ae3c

Browse files
[PropertyAccessor] fix encoding of cache keys
1 parent 7f310b4 commit a22ae3c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Symfony/Component/PropertyAccess/PropertyAccessor.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ private function readProperty($zval, $property)
508508
*/
509509
private function getReadAccessInfo($class, $property)
510510
{
511-
$key = (false !== strpos($class, '@') ? rawurlencode($class) : $class).'..'.$property;
511+
$key = false !== strpbrk($key = $class.'..'.$property, '{}()/@:') ? rawurlencode($key) : $key;
512512

513513
if (isset($this->readPropertyCache[$key])) {
514514
return $this->readPropertyCache[$key];
@@ -687,7 +687,7 @@ private function writeCollection($zval, $property, $collection, $addMethod, $rem
687687
*/
688688
private function getWriteAccessInfo($class, $property, $value)
689689
{
690-
$key = (false !== strpos($class, '@') ? rawurlencode($class) : $class).'..'.$property;
690+
$key = false !== strpbrk($key = $class.'..'.$property, '{}()/@:') ? rawurlencode($key) : $key;
691691

692692
if (isset($this->writePropertyCache[$key])) {
693693
return $this->writePropertyCache[$key];
@@ -868,7 +868,8 @@ private function getPropertyPath($propertyPath)
868868
}
869869

870870
if ($this->cacheItemPool) {
871-
$item = $this->cacheItemPool->getItem(self::CACHE_PREFIX_PROPERTY_PATH.$propertyPath);
871+
$key = false !== strpbrk($propertyPath, '{}()/@:') ? rawurlencode($propertyPath) : $propertyPath;
872+
$item = $this->cacheItemPool->getItem(self::CACHE_PREFIX_PROPERTY_PATH.str_replace('\\', '.', $key));
872873
if ($item->isHit()) {
873874
return $this->propertyPathCache[$propertyPath] = $item->get();
874875
}

0 commit comments

Comments
 (0)
0