diff --git a/core/manipulate-dom.js b/core/manipulate-dom.js index 18ed55c3..16af567a 100644 --- a/core/manipulate-dom.js +++ b/core/manipulate-dom.js @@ -52,7 +52,7 @@ manipulateDOM._removeCrossOriginAndIntegrityAttr = function (details) { if (!isAllowlisted && mimeType === 'text/html') { - let asciiDecoder, decoder, encoder, charset, isFirstData, filter, data; + let initDecoder, decoder, encoder, charset, isFirstData, filter, data; charset = (/charset\s*=/).test(header.value) && header.value.replace(/^.*?charset\s*=\s*/, '').replace(/["']?/g, ''); @@ -63,7 +63,8 @@ manipulateDOM._removeCrossOriginAndIntegrityAttr = function (details) { return; } - asciiDecoder = new TextDecoder('ASCII'); + // Use charset of the response header in the initial TextDecoder. ASCII only as fallback. + initDecoder = new TextDecoder(charset === false ? 'ASCII' : charset); encoder = new TextEncoder(); isFirstData = true; filter = browser.webRequest.filterResponseData(details.requestId); @@ -92,7 +93,7 @@ manipulateDOM._removeCrossOriginAndIntegrityAttr = function (details) { uint8View = new Uint8Array(chunk); } - htmlHead = asciiDecoder.decode(uint8View, {'stream': false}); + htmlHead = initDecoder.decode(uint8View, {'stream': false}); // eslint-disable-next-line no-useless-escape charsetMatch = htmlHead.match(/"'\/]+)["'>\/]/i); if (charsetMatch === null) { diff --git a/pages/updates/updates.html b/pages/updates/updates.html index f5e9f4f6..9d0a4fd1 100644 --- a/pages/updates/updates.html +++ b/pages/updates/updates.html @@ -28,6 +28,7 @@

Improved

Mapping