Skip to content

Commit d3fd7a8

Browse files
committed
Fix #42 - Serialization of non-ascii characters may result in an incomplete payload being sent across the wire
1 parent c141e2a commit d3fd7a8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/util.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -1553,9 +1553,11 @@ export namespace util {
15531553
* @inheritDoc
15541554
*/
15551555
public serialize (obj: any): Buffer {
1556-
return Buffer.concat(
1557-
[Buffer.from(JSONSerializer.JSON_SERIALIZER_PREFIX.toString()),
1558-
Buffer.from(JSON.stringify(obj))]);
1556+
const headerBuf = Buffer.alloc(1);
1557+
headerBuf.writeInt8(JSONSerializer.JSON_SERIALIZER_PREFIX)
1558+
const valBuf = Buffer.from(JSON.stringify(obj));
1559+
1560+
return Buffer.concat([headerBuf, valBuf], headerBuf.length + valBuf.length);
15591561
}
15601562

15611563
/**

0 commit comments

Comments
 (0)