From 0190fdaf3d80e4c4119621d306e7842fddb8964d Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Wed, 25 Dec 2019 08:44:42 -0500 Subject: [PATCH] Add back missing tab context properties These properties, used to detect/act on/report unencrypted connection, were erroneously removed when importing uBO's code en-bloc. Related issue: - https://github.com/uBlockOrigin/uMatrix-issues/issues/212 --- src/js/tab.js | 6 ++++++ src/js/uritools.js | 12 ++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/js/tab.js b/src/js/tab.js index c390b19..0f8d7d6 100644 --- a/src/js/tab.js +++ b/src/js/tab.js @@ -180,9 +180,11 @@ housekeep itself. this.stack = []; this.rawURL = this.normalURL = + this.scheme = this.origin = this.rootHostname = this.rootDomain = ''; + this.secure = false; this.commitTimer = null; this.gcTimer = null; this.onGCBarrier = false; @@ -266,19 +268,23 @@ housekeep itself. if ( this.stack.length === 0 ) { this.rawURL = this.normalURL = + this.scheme = this.origin = this.rootHostname = this.rootDomain = ''; + this.secure = false; return; } const stackEntry = this.stack[this.stack.length - 1]; this.rawURL = stackEntry.url; this.normalURL = µm.normalizePageURL(this.tabId, this.rawURL); + this.scheme = µm.URI.schemeFromURI(this.rawURL); this.origin = µm.URI.originFromURI(this.normalURL); this.rootHostname = µm.URI.hostnameFromURI(this.origin); this.rootDomain = µm.URI.domainFromHostname(this.rootHostname) || this.rootHostname; + this.secure = µm.URI.isSecureScheme(this.scheme); }; // Called whenever a candidate root URL is spotted for the tab. diff --git a/src/js/uritools.js b/src/js/uritools.js index d4821cb..a78f9a3 100644 --- a/src/js/uritools.js +++ b/src/js/uritools.js @@ -31,7 +31,7 @@ Naming convention from https://en.wikipedia.org/wiki/URI_scheme#Examples /******************************************************************************/ -µMatrix.URI = (function() { +µMatrix.URI = (( ) => { /******************************************************************************/ @@ -70,7 +70,7 @@ const reHostFromNakedAuthority = /^[0-9a-z._-]+[0-9a-z]$/i; /******************************************************************************/ -var reset = function(o) { +const reset = function(o) { o.scheme = ''; o.hostname = ''; o._ipv4 = undefined; @@ -82,7 +82,7 @@ var reset = function(o) { return o; }; -var resetAuthority = function(o) { +const resetAuthority = function(o) { o.hostname = ''; o._ipv4 = undefined; o._ipv6 = undefined; @@ -240,12 +240,12 @@ URI.isNetworkScheme = function(scheme) { /******************************************************************************/ +const reSecureScheme = /^(?:http|ws|ftp)s\b/; + URI.isSecureScheme = function(scheme) { - return this.reSecureScheme.test(scheme); + return reSecureScheme.test(scheme); }; -URI.reSecureScheme = /^(?:https|wss|ftps)\b/; - /******************************************************************************/ URI.hostnameFromURI = vAPI.hostnameFromURI;