From 946424cf864a9185bd4203caa7ed9e54f36d646e Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Tue, 10 Jan 2023 09:26:30 -0800 Subject: buffer.toString(undefined) should be UTF-8 --- src/bun.js/bindings/JSBuffer.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/bun.js/bindings/JSBuffer.cpp b/src/bun.js/bindings/JSBuffer.cpp index ebaec3def..623c67bcb 100644 --- a/src/bun.js/bindings/JSBuffer.cpp +++ b/src/bun.js/bindings/JSBuffer.cpp @@ -1147,6 +1147,11 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_toStringBody(JSC::JS case 3: case 1: { JSC::JSValue arg1 = callFrame->uncheckedArgument(0); + if (arg1.isUndefined()) { + encoding = WebCore::BufferEncodingType::utf8; + break; + } + std::optional encoded = parseEnumeration(*lexicalGlobalObject, arg1); if (!encoded) { throwTypeError(lexicalGlobalObject, scope, "Invalid encoding"_s); -- cgit v1.2.3