mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
fix decoding invalid UTF-8 input (#3563)
* fix decoding invalid UTF-8 input Close: https://github.com/oven-sh/bun/issues/3562 * add unittest
This commit is contained in:
@@ -241,3 +241,12 @@ for (const StringDecoder of [FakeStringDecoderCall, RealStringDecoder]) {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
it("invalid utf-8 input, pr #3562", () => {
|
||||
const decoder = new RealStringDecoder("utf-8");
|
||||
let output = "";
|
||||
output += decoder.write(Buffer.from("B9", "hex"));
|
||||
output += decoder.write(Buffer.from("A9", "hex"));
|
||||
output += decoder.end();
|
||||
expect(output).toStrictEqual("\uFFFD\uFFFD");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user