From 3cc2e04bb03c6ca0e27322c6a71f341a194f7574 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Mon, 18 Apr 2022 14:20:26 -0700 Subject: [PATCH] utils: ensure `TextDecoder` is only removing `utf-8` BOM on `utf-8` encoding --- lib/internal/encoding.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/internal/encoding.js b/lib/internal/encoding.js index def0e9223b84c79..d1ae814ae1fbe6b 100644 --- a/lib/internal/encoding.js +++ b/lib/internal/encoding.js @@ -512,6 +512,7 @@ function makeTextDecoderJS() { this[kHandle].write(input); if (result.length > 0 && + this[kEncoding] === 'utf-8' && !this[kBOMSeen] && !(this[kFlags] & CONVERTER_FLAGS_IGNORE_BOM)) { // If the very first result in the stream is a BOM, and we are not