Fixed: WWW Prefix (#233)

This commit is contained in:
nobody 2021-01-18 19:05:41 +01:00
parent 1b213bea58
commit 8cc77e719f
No known key found for this signature in database
GPG Key ID: 8F6DE3D614FCFD7A
4 changed files with 16 additions and 12 deletions

View File

@ -42,7 +42,7 @@ messenger._handleMessageReceived = function (message, sender, sendResponse) {
}
if (topic === 'domain:fetch-is-allowlisted') {
let allowlistRecord = requestAnalyzer.allowlistedDomains[value] || requestAnalyzer.allowlistedDomains[helpers.getWildcard(value)];
let allowlistRecord = helpers.checkAllowlisted(value);
sendResponse({'value': Boolean(allowlistRecord)});
return MessageResponse.SYNCHRONOUS;

View File

@ -37,9 +37,7 @@ requestAnalyzer.isValidCandidate = function (requestDetails, tabDetails) {
initiatorDomain = Address.EXAMPLE;
}
wildcard = helpers.getWildcard(initiatorDomain);
isAllowlisted = requestAnalyzer.allowlistedDomains[initiatorDomain] || requestAnalyzer.allowlistedDomains[wildcard];
isAllowlisted = helpers.checkAllowlisted(initiatorDomain);
if (isAllowlisted) {
return false;
}

View File

@ -255,7 +255,7 @@ stateManager._domainIsListed = function (domain, listname) {
allowlistRecord = requestAnalyzer.domainsManipulateDOM[domain];
isAllowlisted = Boolean(allowlistRecord);
} else {
allowlistRecord = requestAnalyzer.allowlistedDomains[domain] || requestAnalyzer.allowlistedDomains[helpers.getWildcard(domain)];
allowlistRecord = helpers.checkAllowlisted(domain);
isAllowlisted = Boolean(allowlistRecord);
}

View File

@ -89,13 +89,7 @@ helpers.languageIsFullySupported = function (language) {
};
helpers.normalizeDomain = function (domain) {
domain = domain.toLowerCase().trim();
if (domain.startsWith(Address.WWW_PREFIX)) {
domain = domain.slice(Address.WWW_PREFIX.length);
}
return domain;
return domain.toLowerCase().trim();
};
helpers.extractDomainFromUrl = function (url, normalize) {
@ -137,6 +131,18 @@ helpers.getWildcard = function(initiatorDomain) {
};
helpers.checkAllowlisted = function(domain) {
let domainWithoutPrefix, wildcard, list;
if (domain.startsWith(Address.WWW_PREFIX)) {
domainWithoutPrefix = domain.slice(Address.WWW_PREFIX.length);
}
wildcard = helpers.getWildcard(domain);
list = requestAnalyzer.allowlistedDomains;
return list[domain] || list[domainWithoutPrefix] || list[wildcard] || list[domainWithoutPrefix];
};
helpers.extractFilenameFromPath = function (path) {
let pathSegments, filename;