1
0
mirror of https://codeberg.org/nobody/LocalCDN.git synced 2024-12-23 08:30:38 +01:00

Considers existing charset in header

This commit is contained in:
nobody42 2020-05-17 08:43:27 +02:00
parent 6df8493bb6
commit 88d6946fa0
No known key found for this signature in database
GPG Key ID: AB5145CF05BFE119

View File

@ -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);