1
0
mirror of https://codeberg.org/nobody/LocalCDN.git synced 2025-01-10 17:23:18 +01:00

Updated charset check

This commit is contained in:
nobody 2020-05-23 16:56:16 +02:00
parent 14c0adc281
commit 5614551d1b
No known key found for this signature in database
GPG Key ID: 8F6DE3D614FCFD7A

View File

@ -43,15 +43,16 @@ manipulateDOM._removeCrossOriginAndIntegrityAttr = function (details) {
let asciiDecoder, decoder, encoder, charset, isFirstData, filter; let asciiDecoder, decoder, encoder, charset, isFirstData, filter;
asciiDecoder = new TextDecoder('ASCII');
encoder = new TextEncoder();
charset = /charset\s*=/.test(header.value) && header.value.replace(/^.*?charset\s*=\s*/, '').replace(/["']?/g, ''); charset = /charset\s*=/.test(header.value) && header.value.replace(/^.*?charset\s*=\s*/, '').replace(/["']?/g, '');
// Check if charset is supported by TextDecoder() // Check if charset is supported by TextDecoder()
if(EncodingTypes[charset.toString().toLowerCase()] == undefined){ if(/charset\s*=/.test(header.value) && !EncodingTypes[charset.toString().toLowerCase()]){
charset = false; console.error('[ LocalCDN ] Unsupported charset: ' + charset);
return;
} }
asciiDecoder = new TextDecoder('ASCII');
encoder = new TextEncoder();
isFirstData = true; isFirstData = true;
filter = browser.webRequest.filterResponseData(details.requestId); filter = browser.webRequest.filterResponseData(details.requestId);