Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd7cb006

Browse files
committed
bug#25340 [Serializer] Unset attributes when creating child context (dunglas)
This PR was merged into the 3.3 branch.Discussion----------[Serializer] Unset attributes when creating child context | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/aIn some cases, the `attributes` key isn't overrode when creating the context passed to nested normalizers. It's definitely a bug, but an attacker cannot access to non public data (ignored attributes are checked before the `attributes` key). However some data that must be public may be missing as highlighted by the test.I've introduced the initial bug here:#18834Commits-------4ff9d99 [Serializer] Unset attributes when creating child context
2 parents6e7e684 +4ff9d99 commitd7cb006

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

‎src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,8 @@ protected function createChildContext(array $parentContext, $attribute)
402402
{
403403
if (isset($parentContext[self::ATTRIBUTES][$attribute])) {
404404
$parentContext[self::ATTRIBUTES] =$parentContext[self::ATTRIBUTES][$attribute];
405+
}else {
406+
unset($parentContext[self::ATTRIBUTES]);
405407
}
406408

407409
return$parentContext;

‎src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,16 @@ public function testAttributesContextNormalize()
673673
),
674674
$serializer->normalize($objectDummy,null,$context)
675675
);
676+
677+
$context =array('attributes' =>array('foo','baz','object'));
678+
$this->assertEquals(
679+
array(
680+
'foo' =>'foo',
681+
'baz' =>true,
682+
'object' =>array('foo' =>'innerFoo','bar' =>'innerBar'),
683+
),
684+
$serializer->normalize($objectDummy,null,$context)
685+
);
676686
}
677687

678688
publicfunctiontestAttributesContextDenormalize()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp