Skip to content
This repository was archived by the owner on Nov 6, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update chromium/background.js , Fix #13568
  • Loading branch information
Chan Chak Shing committed Nov 12, 2017
commit 9fcbe4cbdeb84a9b6c2cfa25fce6f53c828a2ec5
28 changes: 13 additions & 15 deletions chromium/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,17 @@ function onBeforeRequest(details) {
return;
}

const uri = new URL(details.url);
let uri = new URL(details.url);

// Normalise hosts with tailing dots, e.g. "www.example.com."
let canonical_host = uri.hostname;
while (canonical_host.charAt(canonical_host.length - 1) == ".") {
canonical_host = canonical_host.slice(0, -1);
uri.hostname = canonical_host;
}

// Should the request be canceled?
var shouldCancel = (
const shouldCancel = (
httpNowhereOn &&
uri.protocol === 'http:' &&
!/\.onion$/.test(uri.hostname) &&
Expand All @@ -242,17 +249,9 @@ function onBeforeRequest(details) {
!/^0\.0\.0\.0$/.test(uri.hostname)
);

// Normalise hosts such as "www.example.com."
var canonical_host = uri.hostname;
if (canonical_host.charAt(canonical_host.length - 1) == ".") {
while (canonical_host.charAt(canonical_host.length - 1) == ".")
canonical_host = canonical_host.slice(0,-1);
uri.hostname = canonical_host;
}

// If there is a username / password, put them aside during the ruleset
// analysis process
var using_credentials_in_url = false;
let using_credentials_in_url = false;
let tmp_user;
let tmp_pass;
if (uri.password || uri.username) {
Expand All @@ -276,14 +275,13 @@ function onBeforeRequest(details) {
activeRulesets.removeTab(details.tabId);
}

var potentiallyApplicable = all_rules.potentiallyApplicableRulesets(uri.hostname);
var potentiallyApplicable = all_rules.potentiallyApplicableRulesets(canonical_host);

if (redirectCounter.get(details.requestId) >= 8) {
util.log(util.NOTE, "Redirect counter hit for " + canonical_url);
urlBlacklist.add(canonical_url);
var hostname = uri.hostname;
rules.settings.domainBlacklist.add(hostname);
util.log(util.WARN, "Domain blacklisted " + hostname);
rules.settings.domainBlacklist.add(canonical_host);
util.log(util.WARN, "Domain blacklisted " + canonical_host);
return {cancel: shouldCancel};
}

Expand Down