mirror of https://github.com/gorhill/uBlock.git
this fixes #1078
This commit is contained in:
parent
4a07482d46
commit
cc3f33ef9a
|
@ -448,26 +448,27 @@ var pageStoreJunkyardMax = 10;
|
|||
|
||||
/******************************************************************************/
|
||||
|
||||
var PageStore = function(tabId, pageURL) {
|
||||
this.init(tabId, pageURL);
|
||||
var PageStore = function(tabId, rawURL, pageURL) {
|
||||
this.init(tabId, rawURL, pageURL);
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
PageStore.factory = function(tabId, pageURL) {
|
||||
PageStore.factory = function(tabId, rawURL, pageURL) {
|
||||
var entry = pageStoreJunkyard.pop();
|
||||
if ( entry === undefined ) {
|
||||
entry = new PageStore(tabId, pageURL);
|
||||
entry = new PageStore(tabId, rawURL, pageURL);
|
||||
} else {
|
||||
entry.init(tabId, pageURL);
|
||||
entry.init(tabId, rawURL, pageURL);
|
||||
}
|
||||
return entry;
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
PageStore.prototype.init = function(tabId, pageURL) {
|
||||
PageStore.prototype.init = function(tabId, rawURL, pageURL) {
|
||||
this.tabId = tabId;
|
||||
this.rawURL = rawURL;
|
||||
this.pageURL = pageURL;
|
||||
this.pageHostname = µb.URI.hostnameFromURI(pageURL);
|
||||
|
||||
|
@ -507,7 +508,7 @@ PageStore.prototype.init = function(tabId, pageURL) {
|
|||
|
||||
/******************************************************************************/
|
||||
|
||||
PageStore.prototype.reuse = function(pageURL, context) {
|
||||
PageStore.prototype.reuse = function(rawURL, pageURL, context) {
|
||||
// We can't do this: when force refreshing a page, the page store data
|
||||
// needs to be reset
|
||||
//if ( pageURL === this.pageURL ) {
|
||||
|
@ -520,6 +521,7 @@ PageStore.prototype.reuse = function(pageURL, context) {
|
|||
// video thumbnail would not work, because the frame hierarchy structure
|
||||
// was flushed from memory, while not really being flushed on the page.
|
||||
if ( context === 'tabUpdated' ) {
|
||||
this.rawURL = rawURL;
|
||||
this.pageURL = pageURL;
|
||||
this.pageHostname = µb.URI.hostnameFromURI(pageURL);
|
||||
this.pageDomain = µb.URI.domainFromHostname(this.pageHostname) || this.pageHostname;
|
||||
|
@ -535,7 +537,7 @@ PageStore.prototype.reuse = function(pageURL, context) {
|
|||
// A new page is completely reloaded from scratch, reset all.
|
||||
this.disposeFrameStores();
|
||||
this.netFilteringCache = this.netFilteringCache.dispose();
|
||||
this.init(this.tabId, pageURL);
|
||||
this.init(this.tabId, rawURL, pageURL);
|
||||
return this;
|
||||
};
|
||||
|
||||
|
@ -548,7 +550,7 @@ PageStore.prototype.dispose = function() {
|
|||
// need to release the memory taken by these, which can amount to
|
||||
// sizeable enough chunks (especially requests, through the request URL
|
||||
// used as a key).
|
||||
this.pageURL =
|
||||
this.rawURL = this.pageURL =
|
||||
this.pageHostname = this.pageDomain =
|
||||
this.rootHostname = this.rootDomain =
|
||||
this.requestURL = this.requestHostname = this.requestType = '';
|
||||
|
@ -594,8 +596,13 @@ PageStore.prototype.setFrame = function(frameId, frameURL) {
|
|||
/******************************************************************************/
|
||||
|
||||
PageStore.prototype.getNetFilteringSwitch = function() {
|
||||
// https://github.com/gorhill/uBlock/issues/1078
|
||||
// Use both the raw and normalized URLs.
|
||||
if ( this.netFilteringReadTime < µb.netWhitelistModifyTime ) {
|
||||
this.netFiltering = µb.getNetFilteringSwitch(this.pageURL);
|
||||
if ( this.netFiltering && this.rawURL !== this.pageURL ) {
|
||||
this.netFiltering = µb.getNetFilteringSwitch(this.rawURL);
|
||||
}
|
||||
this.netFilteringReadTime = Date.now();
|
||||
}
|
||||
return this.netFiltering;
|
||||
|
|
|
@ -198,7 +198,7 @@ vAPI.tabs.registerListeners();
|
|||
|
||||
// Tab is not bound
|
||||
if ( !pageStore ) {
|
||||
return this.pageStores[tabId] = this.PageStore.factory(tabId, normalURL);
|
||||
return this.pageStores[tabId] = this.PageStore.factory(tabId, pageURL, normalURL);
|
||||
}
|
||||
|
||||
// https://github.com/gorhill/uBlock/issues/516
|
||||
|
@ -210,7 +210,7 @@ vAPI.tabs.registerListeners();
|
|||
// Rebind according to context. We rebind even if the URL did not change,
|
||||
// as maybe the tab was force-reloaded, in which case the page stats must
|
||||
// be all reset.
|
||||
pageStore.reuse(normalURL, context);
|
||||
pageStore.reuse(pageURL, normalURL, context);
|
||||
|
||||
return pageStore;
|
||||
};
|
||||
|
@ -248,6 +248,7 @@ vAPI.tabs.registerListeners();
|
|||
|
||||
µb.pageStores[vAPI.noTabId] = µb.PageStore.factory(
|
||||
vAPI.noTabId,
|
||||
'',
|
||||
µb.normalizePageURL(vAPI.noTabId)
|
||||
);
|
||||
|
||||
|
|
|
@ -66,18 +66,16 @@ var matchWhitelistDirective = function(url, hostname, directive) {
|
|||
|
||||
µBlock.getNetFilteringSwitch = function(url) {
|
||||
var netWhitelist = this.netWhitelist;
|
||||
var buckets, i;
|
||||
var pos = url.indexOf('#');
|
||||
var targetURL = pos !== -1 ? url.slice(0, pos) : url;
|
||||
var targetHostname = this.URI.hostnameFromURI(targetURL);
|
||||
var buckets, i, pos;
|
||||
var targetHostname = this.URI.hostnameFromURI(url);
|
||||
var key = targetHostname;
|
||||
for (;;) {
|
||||
if ( netWhitelist.hasOwnProperty(key) ) {
|
||||
buckets = netWhitelist[key];
|
||||
i = buckets.length;
|
||||
while ( i-- ) {
|
||||
if ( matchWhitelistDirective(targetURL, targetHostname, buckets[i]) ) {
|
||||
// console.log('"%s" matche url "%s"', buckets[i], targetURL);
|
||||
if ( matchWhitelistDirective(url, targetHostname, buckets[i]) ) {
|
||||
// console.log('"%s" matche url "%s"', buckets[i], url);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -286,7 +284,6 @@ var matchWhitelistDirective = function(url, hostname, directive) {
|
|||
/******************************************************************************/
|
||||
|
||||
µBlock.toggleFirewallRule = function(details) {
|
||||
var changed = false;
|
||||
if ( details.action !== 0 ) {
|
||||
this.sessionFirewall.setCellZ(details.srcHostname, details.desHostname, details.requestType, details.action);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue