Skip to content
This repository was archived by the owner on Nov 15, 2017. It is now read-only.

Commit f406fdd

Browse files
committed
overhead of #301, illustrated
1 parent 1c8fb99 commit f406fdd

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

js/lists.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ PermissionScope.prototype.evaluate = function(type, hostname) {
270270
var cellKey = type + '|' + hostname;
271271
if ( this.white.list[cellKey] ) { return 'gdt'; }
272272
if ( this.black.list[cellKey] ) { return 'rdt'; }
273+
// ** TEST GLOBAL : Issue #301 **
273274
// cell doesn't have own rules, inherit
274275

275276
// [specific hostname, ?]: [parent hostname, ?]
@@ -288,7 +289,8 @@ PermissionScope.prototype.evaluate = function(type, hostname) {
288289
// [any hostname, specific type]: inherits from [any hostname, any type]
289290
if ( type !== '*' ) {
290291
if ( this.white.list['*|*'] ) { return 'gpt'; }
291-
return 'rpt';
292+
// ** TEST GLOBAL : Issue #301 **
293+
return 'rpt';
292294
}
293295

294296
// [any hostname, any type]: inherits from hard-coded block
@@ -297,6 +299,14 @@ PermissionScope.prototype.evaluate = function(type, hostname) {
297299

298300
/******************************************************************************/
299301

302+
// ** TEST GLOBAL : Issue #301 **
303+
//
304+
// if not locally graylisted
305+
// if globally whitelisted
306+
// return 'gdt'
307+
// if globally blacklisted
308+
// return 'rdt'
309+
300310
PermissionScope.prototype.evaluateTypeHostnameCellStrict = function(type, hostname) {
301311
// https://github.com/gorhill/httpswitchboard/issues/29
302312
// direct: specific type, specific hostname
@@ -315,9 +325,11 @@ PermissionScope.prototype.evaluateTypeHostnameCellStrict = function(type, hostna
315325
cellKey = type + '|' + parent;
316326
if ( whitelist[cellKey] ) { return 'gpt'; }
317327
if ( blacklist[cellKey] ) { return 'rpt'; }
328+
// ** TEST GLOBAL : Issue #301 **
318329
}
319330
if ( whitelist[typeKey] ) { return 'gpt'; }
320331
if ( blacklist[typeKey] ) { return 'rpt'; }
332+
// ** TEST GLOBAL : Issue #301 **
321333
return 'gpt';
322334
}
323335
if ( blacklist[cellKey] ) { return 'rpt'; }
@@ -333,9 +345,11 @@ PermissionScope.prototype.evaluateTypeHostnameCellStrict = function(type, hostna
333345
cellKey = type + '|' + parent;
334346
if ( whitelist[cellKey] ) { return 'gpt'; }
335347
if ( blacklist[cellKey] ) { return 'rpt'; }
348+
// ** TEST GLOBAL : Issue #301 **
336349
}
337350
if ( whitelist[typeKey] ) { return 'gpt'; }
338351
if ( blacklist[typeKey] ) { return 'rpt'; }
352+
// ** TEST GLOBAL : Issue #301 **
339353
return 'gpt';
340354
}
341355
if ( ubiquitousBlacklist.test(hostname) ) {
@@ -350,28 +364,34 @@ PermissionScope.prototype.evaluateTypeHostnameCellStrict = function(type, hostna
350364
cellKey = type + '|' + parent;
351365
if ( whitelist[cellKey] ) { return 'gpt'; }
352366
if ( blacklist[cellKey] ) { return 'rpt'; }
367+
// ** TEST GLOBAL : Issue #301 **
353368
cellKey = '*|' + parent;
354369
if ( whitelist[cellKey] ) {
355370
while ( parent = parents[i++] ) {
356371
cellKey = type + '|' + parent;
357372
if ( whitelist[cellKey] ) { return 'gpt'; }
358373
if ( blacklist[cellKey] ) { return 'rpt'; }
374+
// ** TEST GLOBAL : Issue #301 **
359375
}
360376
if ( whitelist[typeKey] ) { return 'gpt'; }
361377
if ( blacklist[typeKey] ) { return 'rpt'; }
378+
// ** TEST GLOBAL : Issue #301 **
362379
return 'gpt';
363380
}
364381
if ( blacklist[cellKey] ) { return 'rpt'; }
382+
// ** TEST GLOBAL : Issue #301 **
365383
if ( !graylist[cellKey] ) {
366384
if ( ubiquitousWhitelist.test(parent) ) {
367385
// Strict blocking: the type column must not be blacklisted
368386
while ( parent = parents[i++] ) {
369387
cellKey = type + '|' + parent;
370388
if ( whitelist[cellKey] ) { return 'gpt'; }
371389
if ( blacklist[cellKey] ) { return 'rpt'; }
390+
// ** TEST GLOBAL : Issue #301 **
372391
}
373392
if ( whitelist[typeKey] ) { return 'gpt'; }
374393
if ( blacklist[typeKey] ) { return 'rpt'; }
394+
// ** TEST GLOBAL : Issue #301 **
375395
return 'gpt';
376396
}
377397
if ( ubiquitousBlacklist.test(parent) ) { return 'rpt'; }
@@ -380,8 +400,10 @@ PermissionScope.prototype.evaluateTypeHostnameCellStrict = function(type, hostna
380400
// specific type, any hostname
381401
if ( whitelist[typeKey] ) { return 'gpt'; }
382402
if ( blacklist[typeKey] ) { return 'rpt'; }
403+
// ** TEST GLOBAL : Issue #301 **
383404
// any type, any hostname
384405
if ( whitelist['*|*'] ) { return 'gpt'; }
406+
// ** TEST GLOBAL : Issue #301 **
385407
return 'rpt';
386408
};
387409

@@ -404,6 +426,7 @@ PermissionScope.prototype.evaluateTypeHostnameCellRelax = function(type, hostnam
404426

405427
if ( whitelist[cellKey] ) { return 'gpt'; }
406428
if ( blacklist[cellKey] ) { return 'rpt'; }
429+
// ** TEST GLOBAL : Issue #301 **
407430
if ( !graylist[cellKey] ) {
408431
if ( ubiquitousWhitelist.test(hostname) ) { return 'gpt'; }
409432
if ( ubiquitousBlacklist.test(hostname) ) { return 'rpt'; }
@@ -417,9 +440,11 @@ PermissionScope.prototype.evaluateTypeHostnameCellRelax = function(type, hostnam
417440
cellKey = type + '|' + parent;
418441
if ( whitelist[cellKey] ) { return 'gpt'; }
419442
if ( blacklist[cellKey] ) { return 'rpt'; }
443+
// ** TEST GLOBAL : Issue #301 **
420444
cellKey = '*|' + parent;
421445
if ( whitelist[cellKey] ) { return 'gpt'; }
422446
if ( blacklist[cellKey] ) { return 'rpt'; }
447+
// ** TEST GLOBAL : Issue #301 **
423448
if ( !graylist[cellKey] ) {
424449
if ( ubiquitousWhitelist.test(parent) ) { return 'gpt'; }
425450
if ( ubiquitousBlacklist.test(parent) ) { return 'rpt'; }
@@ -428,6 +453,7 @@ PermissionScope.prototype.evaluateTypeHostnameCellRelax = function(type, hostnam
428453
// indirect: specific type, any hostname
429454
if ( whitelist[typeKey] ) { return 'gpt'; }
430455
if ( blacklist[typeKey] ) { return 'rpt'; }
456+
// ** TEST GLOBAL : Issue #301 **
431457
// indirect: any type, any hostname
432458
if ( whitelist['*|*'] ) { return 'gpt'; }
433459
return 'rpt';
@@ -439,6 +465,7 @@ PermissionScope.prototype.evaluateHostnameCell = function(hostname) {
439465
// direct: any type, specific hostname
440466
var ubiquitousWhitelist = this.httpsb.ubiquitousWhitelist;
441467
var ubiquitousBlacklist = this.httpsb.ubiquitousBlacklist;
468+
// ** TEST GLOBAL : Issue #301 **
442469
var graylist = this.gray.list;
443470
if ( !graylist['*|' + hostname] ) {
444471
if ( ubiquitousWhitelist.test(hostname) ) { return 'gdt'; }
@@ -452,6 +479,7 @@ PermissionScope.prototype.evaluateHostnameCell = function(hostname) {
452479
cellKey = '*|' + parent;
453480
if ( whitelist[cellKey] ) { return 'gpt'; }
454481
if ( blacklist[cellKey] ) { return 'rpt'; }
482+
// ** TEST GLOBAL : Issue #301 **
455483
if ( !graylist[cellKey] ) {
456484
if ( ubiquitousWhitelist.test(parent) ) { return 'gpt'; }
457485
if ( ubiquitousBlacklist.test(parent) ) { return 'rpt'; }

0 commit comments

Comments
 (0)