From aac6c091c208622adb14e63b8235f981ede161fc Mon Sep 17 00:00:00 2001 From: gorhill Date: Tue, 13 Sep 2016 09:03:00 -0400 Subject: [PATCH 01/13] fix regression from a7fe367eecf2af16d07e8ec69743638cd2b05adf: see https://github.com/uBlockOrigin/uAssets/issues/138#issuecomment-246666723 --- src/js/reverselookup-worker.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/js/reverselookup-worker.js b/src/js/reverselookup-worker.js index ed4f910048a5d..17a99a9811a44 100644 --- a/src/js/reverselookup-worker.js +++ b/src/js/reverselookup-worker.js @@ -157,9 +157,9 @@ var fromCosmeticFilter = function(details) { var domain = details.domain; pos = domain.indexOf('.'); if ( pos !== -1 ) { - var entity = domain.slice(0, pos); - candidates[entity + '.*##' + filter] = new RegExp( - ['c', 'e', reEscape(entity), reEscape(filter)].join('\\v') + + var entity = domain.slice(0, pos) + '.*'; + candidates[entity + '##' + filter] = new RegExp( + ['c', 'h', '\\w+', reEscape(entity), reEscape(filter)].join('\\v') + '(?:\\n|$)' ); } From 08dd67b854002ef04f3192efc53228db5d739aa9 Mon Sep 17 00:00:00 2001 From: gorhill Date: Tue, 13 Sep 2016 11:25:24 -0400 Subject: [PATCH 02/13] fix #1735 --- src/js/tab.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/js/tab.js b/src/js/tab.js index 597896e451790..550f0cf10fd18 100644 --- a/src/js/tab.js +++ b/src/js/tab.js @@ -391,11 +391,15 @@ housekeep itself. return tabContexts[vAPI.noTabId]; }; + // https://github.com/gorhill/uBlock/issues/1735 + // Always push before committing, to allow popup detector code to do its + // job. var commit = function(tabId, url) { var entry = tabContexts[tabId]; if ( entry === undefined ) { entry = push(tabId, url); } else { + entry.push(url); entry.commit(url); } return entry; @@ -534,8 +538,6 @@ vAPI.tabs.onClosed = function(tabId) { // d: close target vAPI.tabs.onPopupUpdated = (function() { - //console.debug('vAPI.tabs.onPopup: details = %o', details); - // The same context object will be reused everytime. This also allows to // remember whether a popup or popunder was matched. var context = {}; @@ -575,9 +577,15 @@ vAPI.tabs.onPopupUpdated = (function() { context.requestType = 'popup'; // https://github.com/gorhill/uBlock/commit/1d448b85b2931412508aa01bf899e0b6f0033626#commitcomment-14944764 - // Ignore bad target URL. On Firefox, an `about:blank` tab may be - // opened for a new tab before it is filled in with the real target URL. - if ( context.requestHostname === '' ) { + // Ignore bad target URL. On Firefox, an `about:blank` tab may be + // opened for a new tab before it is filled in with the real target + // URL. + // https://github.com/gorhill/uBlock/issues/1735 + // Do not bail out on `data:` URI, they are commonly used for popups. + if ( + context.requestHostname === '' && + targetURL.startsWith('data:') === false + ) { return ''; } From 0870aea2eb62da57c77a3d326a5bffe18dba393e Mon Sep 17 00:00:00 2001 From: gorhill Date: Tue, 13 Sep 2016 11:56:13 -0400 Subject: [PATCH 03/13] code review re. #1735 --- src/js/tab.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/js/tab.js b/src/js/tab.js index 550f0cf10fd18..6ca1c781875f4 100644 --- a/src/js/tab.js +++ b/src/js/tab.js @@ -392,15 +392,14 @@ housekeep itself. }; // https://github.com/gorhill/uBlock/issues/1735 - // Always push before committing, to allow popup detector code to do its - // job. + // Filter for popups if actually committing. var commit = function(tabId, url) { var entry = tabContexts[tabId]; if ( entry === undefined ) { entry = push(tabId, url); } else { - entry.push(url); entry.commit(url); + popupCandidateTest(tabId); } return entry; }; From 4e0723e1b5c713ea93c19962816806f1031a22de Mon Sep 17 00:00:00 2001 From: gorhill Date: Tue, 13 Sep 2016 12:49:36 -0400 Subject: [PATCH 04/13] new revision for dev build --- platform/chromium/manifest.json | 2 +- platform/opera/manifest.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/chromium/manifest.json b/platform/chromium/manifest.json index 750869fce5611..cada6cb3b0b97 100644 --- a/platform/chromium/manifest.json +++ b/platform/chromium/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "uBlock Origin", - "version": "1.9.7.1", + "version": "1.9.7.2", "default_locale": "en", "description": "__MSG_extShortDesc__", diff --git a/platform/opera/manifest.json b/platform/opera/manifest.json index 5febad3afb412..d7cf0256eb054 100644 --- a/platform/opera/manifest.json +++ b/platform/opera/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "uBlock Origin", - "version": "1.9.7.1", + "version": "1.9.7.2", "default_locale": "en", "description": "__MSG_extShortDesc__", From a39bd8a1c071e792b3b232f7413d729f960fb5c6 Mon Sep 17 00:00:00 2001 From: gorhill Date: Tue, 13 Sep 2016 15:25:22 -0400 Subject: [PATCH 05/13] fix regression from a7fe367eecf2af16d07e8ec69743638cd2b05adf: see https://github.com/uBlockOrigin/uAssets/issues/101#issuecomment-246777505 --- src/js/cosmetic-filtering.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/cosmetic-filtering.js b/src/js/cosmetic-filtering.js index 58cc598501121..8859530bc770c 100644 --- a/src/js/cosmetic-filtering.js +++ b/src/js/cosmetic-filtering.js @@ -1337,7 +1337,7 @@ FilterContainer.prototype.retrieveUserScripts = function(domain, hostname) { bucket.retrieve(hostname, selectors); } if ( entity !== '' && (bucket = this.userScripts.get(entity)) ) { - bucket.retrieve(hostname, selectors); + bucket.retrieve(entity, selectors); } var i = selectors.length; while ( i-- ) { From 63691a26efec18459795d508db25a1b1f2d4d32c Mon Sep 17 00:00:00 2001 From: gorhill Date: Tue, 13 Sep 2016 15:27:14 -0400 Subject: [PATCH 06/13] new revision for dev build --- platform/chromium/manifest.json | 2 +- platform/opera/manifest.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/chromium/manifest.json b/platform/chromium/manifest.json index cada6cb3b0b97..619e0d695fda5 100644 --- a/platform/chromium/manifest.json +++ b/platform/chromium/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "uBlock Origin", - "version": "1.9.7.2", + "version": "1.9.7.3", "default_locale": "en", "description": "__MSG_extShortDesc__", diff --git a/platform/opera/manifest.json b/platform/opera/manifest.json index d7cf0256eb054..756e3fa81357f 100644 --- a/platform/opera/manifest.json +++ b/platform/opera/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "uBlock Origin", - "version": "1.9.7.2", + "version": "1.9.7.3", "default_locale": "en", "description": "__MSG_extShortDesc__", From 6e81771783f56b720663c648e12f4256725e951b Mon Sep 17 00:00:00 2001 From: gorhill Date: Thu, 15 Sep 2016 09:06:22 -0400 Subject: [PATCH 07/13] #1735: remove spurious whitespaces from data URI description fields --- platform/chromium/vapi-background.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/platform/chromium/vapi-background.js b/platform/chromium/vapi-background.js index 3014ca2f3a7bb..a4c5241684bff 100644 --- a/platform/chromium/vapi-background.js +++ b/platform/chromium/vapi-background.js @@ -240,10 +240,25 @@ vAPI.tabs.registerListeners = function() { // http://raymondhill.net/ublock/popup.html var reGoodForWebRequestAPI = /^https?:\/\//; + // https://forums.lanik.us/viewtopic.php?f=62&t=32826 + // Chromium-based browsers: sanitize target URL. I've seen + // data: URI-based with newline characters, possibly as a way of + // evading filters. There should be no whitespaces in a data: URI's + // standard fields. + var sanitizeURL = function(url) { + if ( url.startsWith('data:') === false ) { return url; } + var pos = url.indexOf(','); + if ( pos === -1 ) { return url; } + var s = url.slice(0, pos); + if ( s.search(/\s/) === -1 ) { return url; } + return s.replace(/\s+/, '') + url.slice(pos); + }; + var onCreatedNavigationTarget = function(details) { //console.debug('onCreatedNavigationTarget: popup candidate tab id %d = "%s"', details.tabId, details.url); if ( reGoodForWebRequestAPI.test(details.url) === false ) { details.frameId = 0; + details.url = sanitizeURL(details.url); onNavigationClient(details); } if ( typeof vAPI.tabs.onPopupCreated === 'function' ) { @@ -261,6 +276,7 @@ vAPI.tabs.registerListeners = function() { if ( details.frameId !== 0 ) { return; } + details.url = sanitizeURL(details.url); onNavigationClient(details); }; @@ -269,6 +285,9 @@ vAPI.tabs.registerListeners = function() { }; var onUpdated = function(tabId, changeInfo, tab) { + if ( changeInfo.url ) { + changeInfo.url = sanitizeURL(changeInfo.url); + } onUpdatedClient(tabId, changeInfo, tab); }; From d516e576ffa7b734c92044f03334535bb8f0ab30 Mon Sep 17 00:00:00 2001 From: gorhill Date: Thu, 15 Sep 2016 09:09:13 -0400 Subject: [PATCH 08/13] reworded comment --- platform/chromium/vapi-background.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/platform/chromium/vapi-background.js b/platform/chromium/vapi-background.js index a4c5241684bff..bd4e5eb3fef65 100644 --- a/platform/chromium/vapi-background.js +++ b/platform/chromium/vapi-background.js @@ -241,9 +241,9 @@ vAPI.tabs.registerListeners = function() { var reGoodForWebRequestAPI = /^https?:\/\//; // https://forums.lanik.us/viewtopic.php?f=62&t=32826 - // Chromium-based browsers: sanitize target URL. I've seen - // data: URI-based with newline characters, possibly as a way of - // evading filters. There should be no whitespaces in a data: URI's + // Chromium-based browsers: sanitize target URL. I've seen data: URI with + // newline characters in standard fields, possibly as a way of evading + // filters. As per spec, there should be no whitespaces in a data: URI's // standard fields. var sanitizeURL = function(url) { if ( url.startsWith('data:') === false ) { return url; } From d7ed124accf6a32cd2f3485039c2469963fdc81c Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Fri, 16 Sep 2016 08:43:02 -0400 Subject: [PATCH 09/13] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c8cf910dd43fb..667eced44d802 100644 --- a/README.md +++ b/README.md @@ -135,7 +135,7 @@ Also of interest: [Deploying uBlock Origin for Firefox with CCK2 and Group Polic ##### Debian/Ubuntu -Users of Debian 9 or later or Ubuntu 16.04 or later may simply +Thanks to Debian contributor [Sean Whitton](https://qa.debian.org/developer.php?email=spwhitton%40spwhitton.name), users of Debian 9 or later or Ubuntu 16.04 or later may simply `apt-get install xul-ext-ublock-origin`. #### Microsoft Edge From cc36a6896daee776e58a2e0fb9fab4c22edb8e33 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Fri, 16 Sep 2016 08:43:38 -0400 Subject: [PATCH 10/13] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 667eced44d802..f216c8d3809e4 100644 --- a/README.md +++ b/README.md @@ -135,7 +135,7 @@ Also of interest: [Deploying uBlock Origin for Firefox with CCK2 and Group Polic ##### Debian/Ubuntu -Thanks to Debian contributor [Sean Whitton](https://qa.debian.org/developer.php?email=spwhitton%40spwhitton.name), users of Debian 9 or later or Ubuntu 16.04 or later may simply +Thanks to Debian contributor [Sean Whitton](https://wiki.debian.org/SeanWhitton), users of Debian 9 or later or Ubuntu 16.04 or later may simply `apt-get install xul-ext-ublock-origin`. #### Microsoft Edge From 269c35a04a668927d7fe917ba5f175efc92c4db2 Mon Sep 17 00:00:00 2001 From: gorhill Date: Fri, 16 Sep 2016 17:41:17 -0400 Subject: [PATCH 11/13] fix #1997 --- src/js/background.js | 1 + src/js/messaging.js | 2 +- src/js/popup.js | 4 +--- src/js/utils.js | 12 ++++++++++++ src/popup.html | 2 +- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/js/background.js b/src/js/background.js index 1a384b5888b51..c63d680b3c804 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -50,6 +50,7 @@ return { userSettings: { advancedUserEnabled: false, + alwaysDetachLogger: false, autoUpdate: true, cloudStorageEnabled: false, collapseBlocked: true, diff --git a/src/js/messaging.js b/src/js/messaging.js index 5717e4704838f..4d44872199950 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -139,7 +139,7 @@ var onMessage = function(request, sender, callback) { break; case 'gotoURL': - vAPI.tabs.open(request.details); + µb.openNewTab(request.details); break; case 'reloadTab': diff --git a/src/js/popup.js b/src/js/popup.js index c42e9d114b2c5..7f16de3d39a02 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -571,8 +571,6 @@ var gotoURL = function(ev) { ev.preventDefault(); - var rel = this.getAttribute('rel') || ''; - messaging.send( 'popupPanel', { @@ -581,7 +579,7 @@ var gotoURL = function(ev) { url: this.getAttribute('href'), select: true, index: -1, - popup: rel === 'popup' && ev.shiftKey + shiftKey: ev.shiftKey } } ); diff --git a/src/js/utils.js b/src/js/utils.js index 2dde6c95ecd39..44b242e76f0bd 100644 --- a/src/js/utils.js +++ b/src/js/utils.js @@ -210,3 +210,15 @@ }; /******************************************************************************/ + +µBlock.openNewTab = function(details) { + if ( details.url.startsWith('logger-ui.html') ) { + if ( details.shiftKey ) { + this.userSettings.alwaysDetachLogger = !this.userSettings.alwaysDetachLogger; + } + details.popup = this.userSettings.alwaysDetachLogger; + } + vAPI.tabs.open(details); +}; + +/******************************************************************************/ diff --git a/src/popup.html b/src/popup.html index 493808009908b..6da2a6f60a86d 100644 --- a/src/popup.html +++ b/src/popup.html @@ -18,7 +18,7 @@

 

   - +

?

From ef0a7ed5cb807900cb9a6d6a926ec972a57471db Mon Sep 17 00:00:00 2001 From: gorhill Date: Fri, 16 Sep 2016 19:12:16 -0400 Subject: [PATCH 12/13] code review re. #1997: be sure the setting is persisted --- src/js/utils.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/js/utils.js b/src/js/utils.js index 44b242e76f0bd..2d5a661171698 100644 --- a/src/js/utils.js +++ b/src/js/utils.js @@ -214,7 +214,10 @@ µBlock.openNewTab = function(details) { if ( details.url.startsWith('logger-ui.html') ) { if ( details.shiftKey ) { - this.userSettings.alwaysDetachLogger = !this.userSettings.alwaysDetachLogger; + this.changeUserSettings( + 'alwaysDetachLogger', + !this.userSettings.alwaysDetachLogger + ); } details.popup = this.userSettings.alwaysDetachLogger; } From 40a85f8c04840ae5f5875c1e8b5fa17578c5bd1a Mon Sep 17 00:00:00 2001 From: gorhill Date: Fri, 16 Sep 2016 19:14:03 -0400 Subject: [PATCH 13/13] new revision for dev build --- platform/chromium/manifest.json | 2 +- platform/opera/manifest.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/chromium/manifest.json b/platform/chromium/manifest.json index 619e0d695fda5..11f43225a6ef9 100644 --- a/platform/chromium/manifest.json +++ b/platform/chromium/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "uBlock Origin", - "version": "1.9.7.3", + "version": "1.9.7.4", "default_locale": "en", "description": "__MSG_extShortDesc__", diff --git a/platform/opera/manifest.json b/platform/opera/manifest.json index 756e3fa81357f..d765e998598e1 100644 --- a/platform/opera/manifest.json +++ b/platform/opera/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "uBlock Origin", - "version": "1.9.7.3", + "version": "1.9.7.4", "default_locale": "en", "description": "__MSG_extShortDesc__",