From c54ab6046a23a53a4c40ba25bfe68cc7f93c92ba Mon Sep 17 00:00:00 2001 From: William Budington Date: Mon, 18 Jun 2018 14:42:36 -0700 Subject: [PATCH] When 'Block all unencrypted requests' is checked, FTP is still allowed. This is a fix for Chromium. Firefox still doesn't recognize the special string for FTP urls. --- chromium/background-scripts/background.js | 14 ++++++++++---- chromium/manifest.json | 5 +++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/chromium/background-scripts/background.js b/chromium/background-scripts/background.js index 6a7be847b8a0..185e42841bbd 100644 --- a/chromium/background-scripts/background.js +++ b/chromium/background-scripts/background.js @@ -298,7 +298,7 @@ function onBeforeRequest(details) { // true if the URL is a http:// connection to a remote canonical host, and not // a tor hidden service const shouldCancel = httpNowhereOn && - uri.protocol === 'http:' && + (uri.protocol === 'http:' || uri.protocol === 'ftp:') && uri.hostname.slice(-6) !== '.onion' && uri.hostname !== 'localhost' && !/^127(\.[0-9]{1,3}){3}$/.test(uri.hostname) && @@ -393,8 +393,14 @@ function onBeforeRequest(details) { newuristr = newuristr.replace(/^http:/, "https:"); } } - if (newuristr && newuristr.substring(0, 5) === "http:") { - // Abort early if we're about to redirect to HTTP in HTTP Nowhere mode + if ( + newuristr && + ( + newuristr.substring(0, 5) === "http:" || + newuristr.substring(0, 4) === "ftp:" + ) + ) { + // Abort early if we're about to redirect to HTTP or FTP in HTTP Nowhere mode return {cancel: true}; } } @@ -636,7 +642,7 @@ function onHeadersReceived(details) { // Registers the handler for requests // See: https://github.com/EFForg/https-everywhere/issues/10039 -chrome.webRequest.onBeforeRequest.addListener(onBeforeRequest, {urls: ["*://*/*"]}, ["blocking"]); +chrome.webRequest.onBeforeRequest.addListener(onBeforeRequest, {urls: ["*://*/*", "ftp://*/*"]}, ["blocking"]); // Try to catch redirect loops on URLs we've redirected to HTTPS. chrome.webRequest.onBeforeRedirect.addListener(onBeforeRedirect, {urls: ["https://*/*"]}); diff --git a/chromium/manifest.json b/chromium/manifest.json index 10b776f062e6..74ed533064e8 100644 --- a/chromium/manifest.json +++ b/chromium/manifest.json @@ -48,7 +48,8 @@ "tabs", "cookies", "storage", - "*://*/*" + "*://*/*", + "ftp://*/*" ], "version": "2018.6.21" -} \ No newline at end of file +}