Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ public function testDecodingFailsWithBadFormat()
]);
}

public function testDecodingFailsWithBadBase64Body()
{
$this->expectException(MessageDecodingFailedException::class);
$this->expectExceptionMessageMatches('/Could not decode/');

$serializer = new PhpSerializer();

$serializer->decode([
'body' => 'x',
]);
}

public function testDecodingFailsWithBadClass()
{
$this->expectException(MessageDecodingFailedException::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public function encode(Envelope $envelope): array

private function safelyUnserialize(string $contents)
{
if ('' === $contents) {
throw new MessageDecodingFailedException('Could not decode an empty message using PHP serialization.');
}

$signalingException = new MessageDecodingFailedException(sprintf('Could not decode message using PHP serialization: %s.', $contents));
$prevUnserializeHandler = ini_set('unserialize_callback_func', self::class.'::handleUnserializeCallback');
$prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$prevErrorHandler, $signalingException) {
Expand Down