base64_encoding inside PhpSerializer to avoid null characters
This commit is contained in:
parent
9bcea2e9f4
commit
fe7ad812c7
@ -58,7 +58,7 @@ class PhpSerializerTest extends TestCase
|
|||||||
$serializer = new PhpSerializer();
|
$serializer = new PhpSerializer();
|
||||||
|
|
||||||
$serializer->decode([
|
$serializer->decode([
|
||||||
'body' => 'O:13:"ReceivedSt0mp":0:{}',
|
'body' => base64_encode('O:13:"ReceivedSt0mp":0:{}'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,13 @@ class PhpSerializer implements SerializerInterface
|
|||||||
throw new MessageDecodingFailedException('Encoded envelope should have at least a "body".');
|
throw new MessageDecodingFailedException('Encoded envelope should have at least a "body".');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->safelyUnserialize($encodedEnvelope['body']);
|
$serializeEnvelope = base64_decode($encodedEnvelope['body']);
|
||||||
|
|
||||||
|
if (false === $serializeEnvelope) {
|
||||||
|
throw new MessageDecodingFailedException('The "body" key could not be base64 decoded.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->safelyUnserialize($serializeEnvelope);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,7 +45,7 @@ class PhpSerializer implements SerializerInterface
|
|||||||
public function encode(Envelope $envelope): array
|
public function encode(Envelope $envelope): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'body' => serialize($envelope),
|
'body' => base64_encode(serialize($envelope)),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user