Skip to content
This repository was archived by the owner on Nov 6, 2023. It is now read-only.
Merged
Changes from all commits
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
23 changes: 22 additions & 1 deletion chromium/background-scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -690,13 +690,34 @@ function onErrorOccurred(details) {
*/
function onHeadersReceived(details) {
if (isExtensionEnabled && httpNowhereOn) {
// Do not upgrade the .onion requests in HTTP Nowhere Mode,
// Do not upgrade the .onion requests in EASE mode,
// See https://github.com/EFForg/https-everywhere/pull/14600#discussion_r168072480
const uri = new URL(details.url);
if (uri.hostname.slice(-6) == '.onion') {
return {};
}

// Do not upgrade resources if the first-party domain disbled EASE mode
// This is needed for HTTPS sites serve mixed content and is broken
let firstPartyHost;
if (details.type == "main_frame") {
firstPartyHost = uri.host;
} else {
// In Firefox, documentUrl is preferable here, since it will always be the
// URL in the URL bar, but it was only introduced in FF 54. We should get
// rid of `originUrl` at some point.
if ('documentUrl' in details) { // Firefox 54+
firstPartyHost = new URL(details.documentUrl).host;
} else if ('originUrl' in details) { // Firefox < 54
firstPartyHost = new URL(details.originUrl).host;
} else if('initiator' in details) { // Chrome
firstPartyHost = new URL(details.initiator).host;
}
}
if (disabledList.has(firstPartyHost)) {
return {};
}

let responseHeadersChanged = false;
let cspHeaderFound = false;

Expand Down