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()
25
25
26
26
$ envelope = new Envelope (new DummyMessage ('Hello ' ));
27
27
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 ));
29
31
}
30
32
31
33
public function testDecodingFailsWithMissingBodyKey ()
@@ -58,7 +60,7 @@ public function testDecodingFailsWithBadClass()
58
60
$ serializer = new PhpSerializer ();
59
61
60
62
$ serializer ->decode ([
61
- 'body ' => base64_encode ( 'O:13:"ReceivedSt0mp":0:{} ' ) ,
63
+ 'body ' => 'O:13:"ReceivedSt0mp":0:{} ' ,
62
64
]);
63
65
}
64
66
}
Original file line number Diff line number Diff line change @@ -30,11 +30,7 @@ public function decode(array $encodedEnvelope): Envelope
30
30
throw new MessageDecodingFailedException ('Encoded envelope should have at least a "body". ' );
31
31
}
32
32
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 ' ]);
38
34
39
35
return $ this ->safelyUnserialize ($ serializeEnvelope );
40
36
}
@@ -44,8 +40,10 @@ public function decode(array $encodedEnvelope): Envelope
44
40
*/
45
41
public function encode (Envelope $ envelope ): array
46
42
{
43
+ $ body = addslashes (serialize ($ envelope ));
44
+
47
45
return [
48
- 'body ' => base64_encode ( serialize ( $ envelope )) ,
46
+ 'body ' => $ body ,
49
47
];
50
48
}
51
49
You can’t perform that action at this time.
0 commit comments