From 88d6946fa016397d7b5c98c49eecfd0921609805 Mon Sep 17 00:00:00 2001 From: nobody42 <5514211-nobody42@users.noreply.gitlab.com> Date: Sun, 17 May 2020 08:43:27 +0200 Subject: [PATCH] Considers existing charset in header --- core/manipulate-dom.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/manipulate-dom.js b/core/manipulate-dom.js index 05d21885..00f4a88e 100644 --- a/core/manipulate-dom.js +++ b/core/manipulate-dom.js @@ -49,14 +49,14 @@ manipulateDOM._removeCrossOriginAndIntegrityAttr = function (details) { let mimeType, charset, initiatorDomain, isWhitelisted; mimeType = header.value.replace(/;.*/, '').toLowerCase(); - charset = /charset\s*=/.test(header.value) ? header.value.replace(/^.*?charset\s*=\s*/, '') : 'UTF-8'; + charset = /charset\s*=/.test(header.value) ? header.value.replace(/^.*?charset\s*=\s*/, '') : undefined; initiatorDomain = helpers.extractDomainFromUrl(details.url, true) || Address.EXAMPLE; isWhitelisted = stateManager._domainIsWhitelisted(initiatorDomain); if (!isWhitelisted && mimeType === 'text/html') { header.value = 'text/html; charset=UTF-8'; - let decoder = new TextDecoder(manipulateDOM._getEncoding(initiatorDomain)); + let decoder = new TextDecoder(charset === undefined ? manipulateDOM._getEncoding(initiatorDomain) : charset); let encoder = new TextEncoder(); let filter = browser.webRequest.filterResponseData(details.requestId);