From 2a78d7fb99f6943df8578659ca7765f15ad41cca Mon Sep 17 00:00:00 2001 From: gorhill Date: Mon, 6 Oct 2014 17:56:13 -0400 Subject: [PATCH] code review: page's hostname, not request's hostname --- js/net-filtering.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/js/net-filtering.js b/js/net-filtering.js index 9c3ce52ec..6a18cfa3a 100644 --- a/js/net-filtering.js +++ b/js/net-filtering.js @@ -1752,6 +1752,9 @@ FilterContainer.prototype.dynamicFilterStateToOption = { }; FilterContainer.prototype.matchDynamicFilters = function(hostname, requestType, firstParty) { + if ( typeof hostname !== 'string' || hostname === '' ) { + return ''; + } var party = firstParty ? FirstParty : ThirdParty; if ( typeNameToTypeValue.hasOwnProperty(requestType) === false ) { return ''; @@ -1948,9 +1951,12 @@ FilterContainer.prototype.matchStringExactType = function(pageDetails, requestUR FirstParty : ThirdParty; + // This will be used by hostname-based filters + pageHostname = pageDetails.pageHostname || ''; + // Evaluate dynamic filters first. "Block" dynamic filters are always // "important", they override everything else. - var bf = this.matchDynamicFilters(requestHostname, requestType, party === FirstParty); + var bf = this.matchDynamicFilters(pageHostname, requestType, party === FirstParty); if ( bf !== '' && bf.slice(0, 2) !== '@@' ) { return bf; } @@ -1959,9 +1965,6 @@ FilterContainer.prototype.matchStringExactType = function(pageDetails, requestUR var categories = this.categories; var buckets = this.buckets; - // This will be used by hostname-based filters - pageHostname = pageDetails.pageHostname || ''; - // Tokenize only once this.tokenize(url); @@ -2040,16 +2043,16 @@ FilterContainer.prototype.matchString = function(pageDetails, requestURL, reques } } + // This will be used by hostname-based filters + pageHostname = pageDetails.pageHostname || ''; + // Evaluate dynamic filters first. "Block" dynamic filters are always // "important", they override everything else. - var bf = this.matchDynamicFilters(requestHostname, requestType, party === FirstParty); + var bf = this.matchDynamicFilters(pageHostname, requestType, party === FirstParty); if ( bf !== '' && bf.slice(0, 2) !== '@@' ) { return bf; } - // This will be used by hostname-based filters - pageHostname = pageDetails.pageHostname || ''; - var type = typeNameToTypeValue[requestType]; var categories = this.categories; var buckets = this.buckets;