Skip to content

Commit

Permalink
this fixes #1078
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Mar 23, 2015
1 parent 4a07482 commit cc3f33e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
25 changes: 16 additions & 9 deletions src/js/pagestore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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 ) {
Expand All @@ -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;
Expand All @@ -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;
};

Expand All @@ -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 = '';
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/js/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
};
Expand Down Expand Up @@ -248,6 +248,7 @@ vAPI.tabs.registerListeners();

µb.pageStores[vAPI.noTabId] = µb.PageStore.factory(
vAPI.noTabId,
'',
µb.normalizePageURL(vAPI.noTabId)
);

Expand Down
11 changes: 4 additions & 7 deletions src/js/ublock.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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 {
Expand Down

3 comments on commit cc3f33e

@davidrenne
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey FYI:

http://raymondhill.net/ublock/popup.html

Something in this commit causes #7 to be broken where I see:

Example Domain

This domain is established to be used for illustrative examples in documents. You may use this domain in examples without prior coordination or asking for permission.

More information...

When I git checkout to the previous commit to this, the popup is blank. #6 must have been broken a lot longer than this and shows the same page. Let me know if you guys see the same thing.

@gorhill
Copy link
Owner Author

@gorhill gorhill commented on cc3f33e Apr 6, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What browser? I tried with Chromium and it worked as expected.

Edit: Tried with Firefox, and it went fine also.

Need to know browser/version, filter lists selected.

@davidrenne
Copy link

@davidrenne davidrenne commented on cc3f33e Apr 6, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.