Skip to content

Commit

Permalink
Fix #42 - Serialization of non-ascii characters may result in an inco…
Browse files Browse the repository at this point in the history
…mplete payload being sent across the wire
  • Loading branch information
rlubke committed Apr 5, 2022
1 parent c141e2a commit d3fd7a8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1553,9 +1553,11 @@ export namespace util {
* @inheritDoc
*/
public serialize (obj: any): Buffer {
return Buffer.concat(
[Buffer.from(JSONSerializer.JSON_SERIALIZER_PREFIX.toString()),
Buffer.from(JSON.stringify(obj))]);
const headerBuf = Buffer.alloc(1);
headerBuf.writeInt8(JSONSerializer.JSON_SERIALIZER_PREFIX)
const valBuf = Buffer.from(JSON.stringify(obj));

return Buffer.concat([headerBuf, valBuf], headerBuf.length + valBuf.length);
}

/**
Expand Down

0 comments on commit d3fd7a8

Please sign in to comment.