File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed
Tests/Transport/Serialization Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,9 @@ public function testEncodedIsDecodable()
2525
2626 $ envelope = new Envelope (new DummyMessage ('Hello ' ));
2727
28- $ this ->assertEquals ($ envelope , $ serializer ->decode ($ serializer ->encode ($ envelope )));
28+ $ encoded = $ serializer ->encode ($ envelope );
29+ $ this ->assertNotContains ("\0" , $ encoded ['body ' ], 'Does not contain the binary characters ' );
30+ $ this ->assertEquals ($ envelope , $ serializer ->decode ($ encoded ));
2931 }
3032
3133 public function testDecodingFailsWithMissingBodyKey ()
@@ -58,7 +60,7 @@ public function testDecodingFailsWithBadClass()
5860 $ serializer = new PhpSerializer ();
5961
6062 $ serializer ->decode ([
61- 'body ' => base64_encode ( 'O:13:"ReceivedSt0mp":0:{} ' ) ,
63+ 'body ' => 'O:13:"ReceivedSt0mp":0:{} ' ,
6264 ]);
6365 }
6466}
Original file line number Diff line number Diff line change @@ -30,11 +30,7 @@ public function decode(array $encodedEnvelope): Envelope
3030 throw new MessageDecodingFailedException ('Encoded envelope should have at least a "body". ' );
3131 }
3232
33- $ serializeEnvelope = base64_decode ($ encodedEnvelope ['body ' ]);
34-
35- if (false === $ serializeEnvelope ) {
36- throw new MessageDecodingFailedException ('The "body" key could not be base64 decoded. ' );
37- }
33+ $ serializeEnvelope = stripslashes ($ encodedEnvelope ['body ' ]);
3834
3935 return $ this ->safelyUnserialize ($ serializeEnvelope );
4036 }
@@ -44,8 +40,10 @@ public function decode(array $encodedEnvelope): Envelope
4440 */
4541 public function encode (Envelope $ envelope ): array
4642 {
43+ $ body = addslashes (serialize ($ envelope ));
44+
4745 return [
48- 'body ' => base64_encode ( serialize ( $ envelope )) ,
46+ 'body ' => $ body ,
4947 ];
5048 }
5149
You can’t perform that action at this time.
0 commit comments