aboutsummaryrefslogtreecommitdiff
path: root/test/js/node/string_decoder/string-decoder.test.js
diff options
context:
space:
mode:
authorGravatar Ai Hoshino <ambiguous404@gmail.com> 2023-07-08 06:10:49 +0800
committerGravatar GitHub <noreply@github.com> 2023-07-07 15:10:49 -0700
commitc0cf7b4501efe579f0cbd6c2118c00df2ebc6a13 (patch)
tree58fe18bb47d12f7cf1e36fe53c550e29890ef79d /test/js/node/string_decoder/string-decoder.test.js
parentaffd06d05cc756df33854bc1d56e2284ff22b22d (diff)
downloadbun-c0cf7b4501efe579f0cbd6c2118c00df2ebc6a13.tar.gz
bun-c0cf7b4501efe579f0cbd6c2118c00df2ebc6a13.tar.zst
bun-c0cf7b4501efe579f0cbd6c2118c00df2ebc6a13.zip
fix decoding invalid UTF-8 input (#3563)
* fix decoding invalid UTF-8 input Close: https://github.com/oven-sh/bun/issues/3562 * add unittest
Diffstat (limited to 'test/js/node/string_decoder/string-decoder.test.js')
-rw-r--r--test/js/node/string_decoder/string-decoder.test.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/js/node/string_decoder/string-decoder.test.js b/test/js/node/string_decoder/string-decoder.test.js
index f37326678..aba73401a 100644
--- a/test/js/node/string_decoder/string-decoder.test.js
+++ b/test/js/node/string_decoder/string-decoder.test.js
@@ -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");
+});