Fixed encoding problem with some websites (#75)

This commit is contained in:
nobody42 2020-05-16 17:35:26 +02:00
parent c49ec86169
commit 636444cd76
No known key found for this signature in database
GPG Key ID: AB5145CF05BFE119
4 changed files with 31 additions and 3 deletions

View File

@ -92,4 +92,17 @@ const Whitelist = {
const BrowserType = {
'CHROMIUM': chrome.runtime.getURL("/").startsWith("chrome-extension"),
'FIREFOX': chrome.runtime.getURL("/").startsWith("moz-extension")
}
};
const CharsetDomains = {
'dejure.org': 'iso-8859-1',
'privacy-handbuch.de': 'iso-8859-1',
'winfuture.de': 'iso-8859-1',
'drwindows.de': 'iso-8859-1',
'sphinx-soft.com': 'iso-8859-1',
'ekaterinaguseva.ru': 'windows-1251',
'hobbybrauerversand.de': 'iso-8859-1',
'pro-linux.de': 'iso-8859-15',
'gwdg.de': 'windows-1252',
'tyurem.net': 'windows-1251'
};

View File

@ -26,6 +26,18 @@ var manipulateDOM = {};
* Private Methods
*/
manipulateDOM._getEncoding = function (domain) {
let encodingByDomain = CharsetDomains[domain];
if(typeof encodingByDomain === 'undefined') {
return 'UTF-8';
}
return encodingByDomain;
};
manipulateDOM._removeCrossOriginAndIntegrityAttr = function (details) {
// by Jaap (https://gitlab.com/Jaaap)
@ -44,7 +56,7 @@ manipulateDOM._removeCrossOriginAndIntegrityAttr = function (details) {
if (!isWhitelisted && mimeType === 'text/html') {
header.value = 'text/html; charset=UTF-8';
let decoder = new TextDecoder(charset);
let decoder = new TextDecoder(manipulateDOM._getEncoding(initiatorDomain));
let encoder = new TextEncoder();
let filter = browser.webRequest.filterResponseData(details.requestId);

View File

@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "LocalCDN (fork from Decentraleyes)",
"version": "2.2.0",
"version": "2.2.1",
"browser_specific_settings": {
"gecko": {
"id": "{b86e4813-687a-43e6-ab65-0bde4ab75758}",

View File

@ -21,6 +21,9 @@
<div class="subtle-hint">
<div class="topic-label">
New in LocalCDN:
<ul>
<li>Fixed: Encoding problem with some websites (maybe only temporary, because at the moment only 9 websites are affected)</li>
</ul>
</div>
<ul>
<li>Fixed typo in urlize</li>