diff --git a/src/content/lib/request-processor.jsm b/src/content/lib/request-processor.jsm index 8f3dde43..71b54adb 100644 --- a/src/content/lib/request-processor.jsm +++ b/src/content/lib/request-processor.jsm @@ -586,19 +586,6 @@ let RequestProcessor = (function(self) { - let uriSchemeShouldLoadResult = request.checkURISchemes().shouldLoad; - if (uriSchemeShouldLoadResult !== null) { - request.requestResult = new RequestResult(uriSchemeShouldLoadResult, - REQUEST_REASON_COMPATIBILITY); - if (uriSchemeShouldLoadResult === true) { - return accept("Allowing request due to scheme-workaround", request); - } else { - return reject("Blocking request due to scheme-workaround", request); - } - } - - - // Note: If changing the logic here, also make necessary changes to // isAllowedRedirect). diff --git a/src/content/lib/request.jsm b/src/content/lib/request.jsm index 48e212f7..313aff13 100644 --- a/src/content/lib/request.jsm +++ b/src/content/lib/request.jsm @@ -265,130 +265,6 @@ NormalRequest.prototype.getBrowser = function() { }; -// see https://github.com/RequestPolicyContinued/requestpolicy/issues/447 -var knownSchemesWithoutHost = [ - // common schemes - "about", - "feed", - "mediasource", - "mailto", - - // custom schemes - "magnet", - "UT2004", - "gopher", - "spotify", - "greasemonkey-script", - "floatnotes" -]; - -function isKnownSchemeWithoutHost(scheme) { - for (let i = 0, len = knownSchemesWithoutHost.length; i < len; ++i) { - if (scheme == knownSchemesWithoutHost[i]) { - return true; - } - } - return false; -} - -NormalRequest.prototype.checkURISchemes = function() { -/** - * This is a workaround to the problem that RequestPolicy currently cannot - * handle some URIs. This workaround should be removed not later than for - * the stable 1.0 release. - * - * see https://github.com/RequestPolicyContinued/requestpolicy/issues/447 - * - * TODO: solve this problem and remove this workaround. - */ - let unknownSchemesDetected = false; - let uris = [this.aContentLocation, this.aRequestOrigin]; - for (let i = 0; i < 2; ++i) { - let uri = uris[i]; - - // filter URIs which *do* have a host - try { - // this might throw NS_ERROR_FAILURE - if (uri.host) { - continue; - } - } catch(e) {} - - // ensure that the URI has a scheme - try { - if (!uri.scheme) { - throw "no scheme!"; - } - } catch(e) { - Logger.warning(Logger.TYPE_CONTENT, - "URI <" + uri.spec + "> has no scheme!"); - continue; - } - - let scheme = uri.scheme; - if (scheme == "file") { - continue; - } - - if (isKnownSchemeWithoutHost(scheme)) { - Logger.warning(Logger.TYPE_CONTENT, - "RequestPolicy currently cannot handle '" + scheme + "' schemes. " + - "Therefore the request from <" + this.originURI + "> to <" + - this.destURI + "> is allowed (but not recorded)."); - // tell shouldLoad() to return CP_OK: - return {shouldLoad: true}; - } - - // if we get here, the scheme is unknown. try to show a notification. - unknownSchemesDetected = true; - Logger.warning(Logger.TYPE_CONTENT, - "uncatched scheme '" + scheme + "'. The request is from <" + - this.originURI + "> to <" + this.destURI + "> "); - - let chromeWin, browser; - try { - chromeWin = this.getChromeWindow(); - if (!chromeWin) { - throw "The chrome window could not be extracted from aContext."; - } - browser = this.getBrowser(); - } catch (e) { - Logger.warning(Logger.TYPE_INTERNAL, - "The user could not be informed about the " + - "unknown scheme. Error was: " + e, e); - } - - // Try showing the notification multiple times. This is done - // async for two reasons: - // (a) The chrome window's overlay might not be initialized - // yet. - // (b) This function is called by the request processor, so - // it should terminate asap. - Utils.tryMultipleTimes(function (aTriesLeft) { - try { - let overlay = chromeWin.requestpolicy.overlay; - overlay.showSchemeNotification(browser, scheme); - return true; - } catch (e) { - if (aTriesLeft === 0) { - Logger.warning(Logger.TYPE_INTERNAL, - "Failed to show the scheme notification. " + - "Error was: " + e, e); - } else { - Logger.warning(Logger.TYPE_INTERNAL, - "Failed to show the scheme notification. " + - "Trying again..."); - } - return false; - } - }, 3); - - } - - return {shouldLoad: unknownSchemesDetected ? false : null}; -}; - - function RedirectRequest(httpResponse) { diff --git a/src/content/ui/overlay.js b/src/content/ui/overlay.js index c4fe16bc..da44344e 100644 --- a/src/content/ui/overlay.js +++ b/src/content/ui/overlay.js @@ -389,55 +389,6 @@ requestpolicy.overlay = (function() { } }; - /** - * Shows a notification that an unknown scheme has been detected. - * This notification in only necessary for 1.0 beta versions until custom - * URI schemes are supported in RequestPolicy. - * - * issue: https://github.com/RequestPolicyContinued/requestpolicy/issues/447 - * - * @param {browser} browser - * @param {String} scheme - */ - self.showSchemeNotification = function(browser, scheme) { - let notificationBox = gBrowser.getNotificationBox(browser); - let notificationValue = "requestpolicy-scheme-notification"; - - let notification = notificationBox - .getNotificationWithValue(notificationValue); - - var notificationLabel = "This page contains a request with a '" + scheme + - "' scheme which is unknown to RequestPolicy. Please report it."; - - if (notification) { - notification.label = notificationLabel; - } else { - var buttons = [ - { - label : "report this / more info", - accessKey : "r", - popup : null, - callback : function() { - let url = "https://github.com/RequestPolicyContinued/requestpolicy/issues/447"; - window.openUILinkIn(url, "tab", {relatedToCurrent: true}); - } - }, - { - label : "hide", - accessKey : "h", - popup : null, - callback : function() { - // Do nothing. The notification closes when this is called. - } - } - ]; - const priority = notificationBox.PRIORITY_WARNING_LOW; - let iconURI = "chrome://requestpolicy/skin/requestpolicy-icon-blocked.png"; - notificationBox.appendNotification(notificationLabel, notificationValue, - iconURI, priority, buttons); - } - }; - /** * Takes an URI, crops it if necessary, and returns it.