Skip to content

Commit 6b8f145

Browse files
committed
Merge branch '5.3' into 5.4
* 5.3: relax test assertions for forward-compatibility Added missing danish translation string [Messenger] Fix unwrapping the Postgres connection in DBAL 3 Add Hungarian translation of new string improve greek translations [Messenger] fix: TypeError in PhpSerializer::encode() [Config] Fix files sorting in GlobResource Minor doc block wording change
2 parents 469b3dd + 83256aa commit 6b8f145

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Tests/Transport/Serialization/PhpSerializerTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@ public function testDecodingFailsWithBadFormat()
5353
]);
5454
}
5555

56+
public function testDecodingFailsWithBadBase64Body()
57+
{
58+
$this->expectException(MessageDecodingFailedException::class);
59+
$this->expectExceptionMessageMatches('/Could not decode/');
60+
61+
$serializer = new PhpSerializer();
62+
63+
$serializer->decode([
64+
'body' => 'x',
65+
]);
66+
}
67+
5668
public function testDecodingFailsWithBadClass()
5769
{
5870
$this->expectException(MessageDecodingFailedException::class);

Transport/Serialization/PhpSerializer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ public function encode(Envelope $envelope): array
5858

5959
private function safelyUnserialize(string $contents)
6060
{
61+
if ('' === $contents) {
62+
throw new MessageDecodingFailedException('Could not decode an empty message using PHP serialization.');
63+
}
64+
6165
$signalingException = new MessageDecodingFailedException(sprintf('Could not decode message using PHP serialization: %s.', $contents));
6266
$prevUnserializeHandler = ini_set('unserialize_callback_func', self::class.'::handleUnserializeCallback');
6367
$prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$prevErrorHandler, $signalingException) {

0 commit comments

Comments
 (0)