From da9aaf73e19c09c3d283a611ad52fb63642d5af7 Mon Sep 17 00:00:00 2001 From: gorhill Date: Mon, 27 Apr 2015 11:07:51 -0400 Subject: [PATCH 1/3] this fixes https://github.com/gorhill/uBlock/issues/135 and #1329 --- src/js/background.js | 2 ++ src/js/start.js | 10 ++++++++++ src/js/tab.js | 8 +++++--- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/js/background.js b/src/js/background.js index e2a543a3f..d721c6e89 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -71,9 +71,11 @@ return { netWhitelist: {}, netWhitelistModifyTime: 0, netWhitelistDefault: [ + 'about-scheme', 'behind-the-scene', 'chrome-extension-scheme', 'chrome-scheme', + 'loopconversation.about-scheme', 'opera-scheme' ].join('\n').trim(), diff --git a/src/js/start.js b/src/js/start.js index bb7129683..b660644db 100644 --- a/src/js/start.js +++ b/src/js/start.js @@ -81,6 +81,16 @@ var onVersionReady = function(lastVersion) { ); µb.saveWhitelist(); } + // https://github.com/gorhill/uBlock/issues/135#issuecomment-96677379 + // `about:loopconversation` is used by Firefox for its Hello service + if ( lastVersion.localeCompare('0.9.3.5') <= 0 ) { + µb.netWhitelist = µb.whitelistFromString( + µb.stringFromWhitelist(µb.netWhitelist) + + '\n' + + 'loopconversation.about-scheme' + ); + µb.saveWhitelist(); + } if ( lastVersion !== vAPI.app.version ) { vAPI.storage.set({ version: vAPI.app.version }); } diff --git a/src/js/tab.js b/src/js/tab.js index e0ffe35f9..26c90038b 100644 --- a/src/js/tab.js +++ b/src/js/tab.js @@ -55,13 +55,15 @@ var µb = µBlock; return uri.normalizedURI(); } - var url = 'http://' + scheme + '-scheme/'; + var fakeHostname = scheme + '-scheme'; if ( uri.hostname !== '' ) { - url += uri.hostname + '/'; + fakeHostname = uri.hostname + '.' + fakeHostname; + } else if ( scheme === 'about' && uri.path !== '' ) { + fakeHostname = uri.path + '.' + fakeHostname; } - return url; + return 'http://' + fakeHostname + '/'; }; /******************************************************************************/ From b19848583b1e4cdaccffb1289f49e90ebbcf716e Mon Sep 17 00:00:00 2001 From: gorhill Date: Mon, 27 Apr 2015 11:15:36 -0400 Subject: [PATCH 2/3] this fixes gorhill#140 --- platform/chromium/manifest.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/platform/chromium/manifest.json b/platform/chromium/manifest.json index 4ee350b15..951838538 100644 --- a/platform/chromium/manifest.json +++ b/platform/chromium/manifest.json @@ -60,8 +60,5 @@ "http://*/*", "https://*/*" ], - "short_name": "uBlock", - "web_accessible_resources": [ - "document-blocked.html" - ] + "short_name": "uBlock" } From cd8e0f87bd969c0d42697488886efaa1c9fe20cf Mon Sep 17 00:00:00 2001 From: gorhill Date: Mon, 27 Apr 2015 15:09:19 -0400 Subject: [PATCH 3/3] this fixes gorhill#142 and #1331 --- src/js/background.js | 2 +- src/js/static-net-filtering.js | 83 ++++++++++++++++++++++++++-------- 2 files changed, 65 insertions(+), 20 deletions(-) diff --git a/src/js/background.js b/src/js/background.js index d721c6e89..7e9e900c6 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -88,7 +88,7 @@ return { // read-only systemSettings: { - compiledMagic: 'perhodsoahya', + compiledMagic: 'akjbdyreyxgm', selfieMagic: 'spqmeuaftfra' }, diff --git a/src/js/static-net-filtering.js b/src/js/static-net-filtering.js index 9e2b4d588..81e749dc2 100644 --- a/src/js/static-net-filtering.js +++ b/src/js/static-net-filtering.js @@ -571,6 +571,47 @@ FilterPlainHnAnchored.fromSelfie = function(s) { /******************************************************************************/ +// https://github.com/gorhill/uBlock/issues/142 + +var FilterPlainHnAnchoredHostname = function(s, hostname) { + this.s = s; + this.hostname = hostname; +}; + +FilterPlainHnAnchoredHostname.prototype.match = function(url, tokenBeg) { + if ( pageHostnameRegister.slice(-this.hostname.length) !== this.hostname ) { + return false; + } + if ( url.substr(tokenBeg, this.s.length) !== this.s ) { + return false; + } + // Valid only if hostname-valid characters to the left of token + var pos = url.indexOf('://'); + return pos !== -1 && + reURLPostHostnameAnchors.test(url.slice(pos + 3, tokenBeg)) === false; +}; + +FilterPlainHnAnchoredHostname.fid = FilterPlainHnAnchoredHostname.prototype.fid = '||ah'; + +FilterPlainHnAnchoredHostname.prototype.toString = function() { + return '||' + this.s; +}; + +FilterPlainHnAnchoredHostname.prototype.toSelfie = function() { + return this.s + '\t' + this.hostname; +}; + +FilterPlainHnAnchoredHostname.compile = function(details, hostname) { + return details.f + '\t' + hostname; +}; + +FilterPlainHnAnchoredHostname.fromSelfie = function(s) { + var pos = s.indexOf('\t'); + return new FilterPlainHnAnchoredHostname(s.slice(0, pos), s.slice(pos + 1)); +}; + +/******************************************************************************/ + // Generic filter var FilterGeneric = function(s, anchor) { @@ -1141,6 +1182,9 @@ var getHostnameBasedFilterClass = function(details) { if ( details.anchor > 0 ) { return FilterPlainRightAnchoredHostname; } + if ( details.hostnameAnchored ) { + return FilterPlainHnAnchoredHostname; + } if ( details.tokenBeg === 0 ) { return FilterPlainPrefix0Hostname; } @@ -1580,25 +1624,26 @@ FilterContainer.prototype.freeze = function() { /******************************************************************************/ FilterContainer.prototype.factories = { - '[]': FilterBucket, - 'a': FilterPlain, - 'ah': FilterPlainHostname, - '0a': FilterPlainPrefix0, - '0ah': FilterPlainPrefix0Hostname, - '1a': FilterPlainPrefix1, - '1ah': FilterPlainPrefix1Hostname, - '|a': FilterPlainLeftAnchored, - '|ah': FilterPlainLeftAnchoredHostname, - 'a|': FilterPlainRightAnchored, - 'a|h': FilterPlainRightAnchoredHostname, - '||a': FilterPlainHnAnchored, - '//': FilterRegex, - '//h': FilterRegexHostname, - '{h}': FilterHostnameDict, - '_': FilterGeneric, - '_h': FilterGenericHostname, - '||_': FilterGenericHnAnchored, - '||_h': FilterGenericHnAnchoredHostname + '[]': FilterBucket, + 'a': FilterPlain, + 'ah': FilterPlainHostname, + '0a': FilterPlainPrefix0, + '0ah': FilterPlainPrefix0Hostname, + '1a': FilterPlainPrefix1, + '1ah': FilterPlainPrefix1Hostname, + '|a': FilterPlainLeftAnchored, + '|ah': FilterPlainLeftAnchoredHostname, + 'a|': FilterPlainRightAnchored, + 'a|h': FilterPlainRightAnchoredHostname, + '||a': FilterPlainHnAnchored, + '||ah': FilterPlainHnAnchoredHostname, + '//': FilterRegex, + '//h': FilterRegexHostname, + '{h}': FilterHostnameDict, + '_': FilterGeneric, + '_h': FilterGenericHostname, + '||_': FilterGenericHnAnchored, + '||_h': FilterGenericHnAnchoredHostname }; /******************************************************************************/