Skip to content

Commit

Permalink
[PropertyAccessor] fix encoding of cache keys
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Nov 25, 2018
1 parent 7f310b4 commit e3174fc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Symfony/Component/PropertyAccess/PropertyAccessor.php
Expand Up @@ -508,7 +508,7 @@ private function readProperty($zval, $property)
*/
private function getReadAccessInfo($class, $property)
{
$key = (false !== strpos($class, '@') ? rawurlencode($class) : $class).'..'.$property;
$key = false !== strpbrk($key = $class.'..'.$property, '{}()/\@:') ? rawurlencode($key) : $key;

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

if (isset($this->writePropertyCache[$key])) {
return $this->writePropertyCache[$key];
Expand Down Expand Up @@ -868,7 +868,8 @@ private function getPropertyPath($propertyPath)
}

if ($this->cacheItemPool) {
$item = $this->cacheItemPool->getItem(self::CACHE_PREFIX_PROPERTY_PATH.$propertyPath);
$key = false !== strpbrk($propertyPath, '{}()/\@:') ? rawurlencode($propertyPath) : $propertyPath;
$item = $this->cacheItemPool->getItem(self::CACHE_PREFIX_PROPERTY_PATH.$key);
if ($item->isHit()) {
return $this->propertyPathCache[$propertyPath] = $item->get();
}
Expand Down

0 comments on commit e3174fc

Please sign in to comment.