Skip to content

[Serializer] Fix denormalizing abstract part headers in MimeMessageNormalizer #51114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/Symfony/Component/Mime/Tests/MessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ public function testSymfonySerialize()
),
new DataPart('text data', 'text.txt')
);
$body->getHeaders()->addHeader('foo', 'bar');
$e = new Message((new Headers())->addMailboxListHeader('To', ['you@example.com']), $body);
$expected = clone $e;

Expand Down Expand Up @@ -232,7 +233,17 @@ public function testSymfonySerialize()
"class": "Symfony\\\\Component\\\\Mime\\\\Part\\\\DataPart"
}
],
"headers": [],
"headers": {
"foo": [
{
"value": "bar",
"name": "foo",
"lineLength": 76,
"lang": null,
"charset": "utf-8"
}
]
},
"class": "Symfony\\\\Component\\\\Mime\\\\Part\\\\Multipart\\\\MixedPart"
},
"message": null
Expand All @@ -252,7 +263,7 @@ public function testSymfonySerialize()
$this->assertSame($expectedJson, json_encode(json_decode($serialized), \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES));

$n = $serializer->deserialize($serialized, Message::class, 'json');
$this->assertEquals($expected->getHeaders(), $n->getHeaders());
$this->assertEquals($expected, $n);

$serialized = $serializer->serialize($e, 'json');
$this->assertSame($expectedJson, json_encode(json_decode($serialized), \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES));
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Mime/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
"symfony/dependency-injection": "^4.4|^5.0|^6.0",
"symfony/property-access": "^4.4|^5.1|^6.0",
"symfony/property-info": "^4.4|^5.1|^6.0",
"symfony/serializer": "^5.4.14|~6.0.14|^6.1.6"
"symfony/serializer": "^5.4.26|^6.2.13"
},
"conflict": {
"egulias/email-validator": "~3.0.0",
"phpdocumentor/reflection-docblock": "<3.2.2",
"phpdocumentor/type-resolver": "<1.4.0",
"symfony/mailer": "<4.4",
"symfony/serializer": "<5.4.14|>=6.0,<6.0.14|>=6.1,<6.1.6"
"symfony/serializer": "<5.4.26|>=6.2,<6.2.13"
},
"autoload": {
"psr-4": { "Symfony\\Component\\Mime\\": "" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public function denormalize($data, string $type, string $format = null, array $c
if (AbstractPart::class === $type) {
$type = $data['class'];
unset($data['class']);
$data['headers'] = $this->serializer->denormalize($data['headers'], Headers::class, $format, $context);
}

return $this->normalizer->denormalize($data, $type, $format, $context);
Expand Down