Skip to content

Commit 0190fda

Browse files
committed
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: - uBlockOrigin/uMatrix-issues#212
1 parent 0db579d commit 0190fda

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

src/js/tab.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,11 @@ housekeep itself.
180180
this.stack = [];
181181
this.rawURL =
182182
this.normalURL =
183+
this.scheme =
183184
this.origin =
184185
this.rootHostname =
185186
this.rootDomain = '';
187+
this.secure = false;
186188
this.commitTimer = null;
187189
this.gcTimer = null;
188190
this.onGCBarrier = false;
@@ -266,19 +268,23 @@ housekeep itself.
266268
if ( this.stack.length === 0 ) {
267269
this.rawURL =
268270
this.normalURL =
271+
this.scheme =
269272
this.origin =
270273
this.rootHostname =
271274
this.rootDomain = '';
275+
this.secure = false;
272276
return;
273277
}
274278
const stackEntry = this.stack[this.stack.length - 1];
275279
this.rawURL = stackEntry.url;
276280
this.normalURL = µm.normalizePageURL(this.tabId, this.rawURL);
281+
this.scheme = µm.URI.schemeFromURI(this.rawURL);
277282
this.origin = µm.URI.originFromURI(this.normalURL);
278283
this.rootHostname = µm.URI.hostnameFromURI(this.origin);
279284
this.rootDomain =
280285
µm.URI.domainFromHostname(this.rootHostname) ||
281286
this.rootHostname;
287+
this.secure = µm.URI.isSecureScheme(this.scheme);
282288
};
283289

284290
// Called whenever a candidate root URL is spotted for the tab.

src/js/uritools.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Naming convention from https://en.wikipedia.org/wiki/URI_scheme#Examples
3131

3232
/******************************************************************************/
3333

34-
µMatrix.URI = (function() {
34+
µMatrix.URI = (( ) => {
3535

3636
/******************************************************************************/
3737

@@ -70,7 +70,7 @@ const reHostFromNakedAuthority = /^[0-9a-z._-]+[0-9a-z]$/i;
7070

7171
/******************************************************************************/
7272

73-
var reset = function(o) {
73+
const reset = function(o) {
7474
o.scheme = '';
7575
o.hostname = '';
7676
o._ipv4 = undefined;
@@ -82,7 +82,7 @@ var reset = function(o) {
8282
return o;
8383
};
8484

85-
var resetAuthority = function(o) {
85+
const resetAuthority = function(o) {
8686
o.hostname = '';
8787
o._ipv4 = undefined;
8888
o._ipv6 = undefined;
@@ -240,12 +240,12 @@ URI.isNetworkScheme = function(scheme) {
240240

241241
/******************************************************************************/
242242

243+
const reSecureScheme = /^(?:http|ws|ftp)s\b/;
244+
243245
URI.isSecureScheme = function(scheme) {
244-
return this.reSecureScheme.test(scheme);
246+
return reSecureScheme.test(scheme);
245247
};
246248

247-
URI.reSecureScheme = /^(?:https|wss|ftps)\b/;
248-
249249
/******************************************************************************/
250250

251251
URI.hostnameFromURI = vAPI.hostnameFromURI;

0 commit comments

Comments
 (0)