diff --git a/platform/chromium/vapi-background.js b/platform/chromium/vapi-background.js index 37daf8967..7efbc44b0 100644 --- a/platform/chromium/vapi-background.js +++ b/platform/chromium/vapi-background.js @@ -31,9 +31,8 @@ /******************************************************************************/ -self.vAPI = self.vAPI || {}; +var vAPI = self.vAPI = self.vAPI || {}; -var vAPI = self.vAPI; var chrome = self.chrome; var manifest = chrome.runtime.getManifest(); @@ -470,6 +469,16 @@ vAPI.onLoadAllCompleted = function() { /******************************************************************************/ +vAPI.punycodeHostname = function(hostname) { + return hostname; +}; + +vAPI.punycodeURL = function(url) { + return url; +}; + +/******************************************************************************/ + })(); /******************************************************************************/ diff --git a/platform/chromium/vapi-client.js b/platform/chromium/vapi-client.js index b04e5e0aa..9fd6a6e89 100644 --- a/platform/chromium/vapi-client.js +++ b/platform/chromium/vapi-client.js @@ -31,10 +31,9 @@ /******************************************************************************/ -self.vAPI = self.vAPI || {}; +var vAPI = self.vAPI = self.vAPI || {}; var chrome = self.chrome; -var vAPI = self.vAPI; // https://github.com/gorhill/uBlock/issues/456 // Already injected? diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index 992ba2925..ec7055ea1 100644 --- a/platform/firefox/vapi-background.js +++ b/platform/firefox/vapi-background.js @@ -34,7 +34,8 @@ const {Services} = Cu.import('resource://gre/modules/Services.jsm', null); /******************************************************************************/ -self.vAPI = self.vAPI || {}; +var vAPI = self.vAPI = self.vAPI || {}; + vAPI.firefox = true; /******************************************************************************/ @@ -302,16 +303,16 @@ var tabsProgressListener = { var tabId = vAPI.tabs.getTabId(browser); if ( flags & 1 ) { - vAPI.tabs.onUpdated(tabId, {url: location.spec}, { + vAPI.tabs.onUpdated(tabId, {url: location.asciiSpec}, { frameId: 0, tabId: tabId, - url: browser.currentURI.spec + url: browser.currentURI.asciiSpec }); } else if ( location.scheme === 'http' || location.scheme === 'https' ) { vAPI.tabs.onNavigation({ frameId: 0, tabId: tabId, - url: location.spec + url: location.asciiSpec }); } } @@ -427,7 +428,7 @@ vAPI.tabs.get = function(tabId, callback) { index: gBrowser.browsers.indexOf(browser), windowId: windows.indexOf(browser.ownerDocument.defaultView), active: tab === gBrowser.selectedTab, - url: browser.currentURI.spec, + url: browser.currentURI.asciiSpec, title: tab.label }); }; @@ -496,7 +497,7 @@ vAPI.tabs.open = function(details) { for ( tab of tabs ) { var browser = tab.linkedBrowser; - if ( browser.currentURI.spec.replace(rgxHash, '') === url ) { + if ( browser.currentURI.asciiSpec.replace(rgxHash, '') === url ) { browser.ownerDocument.defaultView.gBrowser.selectedTab = tab; return; } @@ -863,7 +864,7 @@ var httpObserver = { var result = vAPI.tabs.onPopup({ tabId: tabId, sourceTabId: sourceTabId, - url: URI.spec + url: URI.asciiSpec }); return result === true; @@ -878,7 +879,7 @@ var httpObserver = { } var result = onBeforeRequest.callback({ - url: channel.URI.spec, + url: channel.URI.asciiSpec, type: type, tabId: details.tabId, frameId: details.frameId, @@ -940,7 +941,7 @@ var httpObserver = { } result = vAPI.net.onHeadersReceived.callback({ - url: URI.spec, + url: URI.asciiSpec, tabId: channelData[1], parentFrameId: -1, responseHeaders: result ? [{name: topic, value: result}] : [] @@ -978,7 +979,7 @@ var httpObserver = { var tabURI = tab.linkedBrowser.currentURI; // Not the best approach - if ( tabURI.spec === this.lastRequest.openerURL ) { + if ( tabURI.asciiSpec === this.lastRequest.openerURL ) { sourceTabId = vAPI.tabs.getTabId(tab); break; } @@ -1422,7 +1423,7 @@ vAPI.contextMenu.create = function(details, callback) { callback(details, { id: vAPI.tabs.getTabId(gContextMenu.browser), - url: gContextMenu.browser.currentURI.spec + url: gContextMenu.browser.currentURI.asciiSpec }); }; @@ -1477,6 +1478,17 @@ window.addEventListener('unload', function() { /******************************************************************************/ +var urlNormalizer = self.URL; +var punycodeHostname = vAPI.punycodeHostname = punycode.toASCII; + +vAPI.punycodeURL = function(url) { + urlNormalizer.href = url; + urlNormalizer.hostname = punycodeHostname(urlNormalizer.hostname); + return urlNormalizer.href; +}; + +/******************************************************************************/ + })(); /******************************************************************************/ diff --git a/platform/safari/vapi-background.js b/platform/safari/vapi-background.js index 3ca98dec1..02b62f863 100644 --- a/platform/safari/vapi-background.js +++ b/platform/safari/vapi-background.js @@ -31,7 +31,8 @@ /******************************************************************************/ -self.vAPI = self.vAPI || {}; +var vAPI = self.vAPI = self.vAPI || {}; + vAPI.safari = true; /******************************************************************************/ @@ -796,4 +797,14 @@ vAPI.onLoadAllCompleted = function() { /******************************************************************************/ +vAPI.punycodeHostname = function(hostname) { + return hostname; +}; + +vAPI.punycodeURL = function(url) { + return url; +}; + +/******************************************************************************/ + })(); diff --git a/src/js/messaging.js b/src/js/messaging.js index afed646ee..2b4efc4e4 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -342,6 +342,7 @@ var filterRequests = function(pageStore, details) { var µburi = µb.URI; // Create evaluation context + details.pageHostname = vAPI.punycodeHostname(details.pageHostname); details.pageDomain = µburi.domainFromHostname(details.pageHostname); details.rootHostname = pageStore.rootHostname; details.rootDomain = pageStore.rootDomain; @@ -356,8 +357,8 @@ var filterRequests = function(pageStore, details) { if ( tagNameToRequestTypeMap.hasOwnProperty(request.tagName) === false ) { continue; } - details.requestURL = request.url; - details.requestHostname = µburi.hostnameFromURI(request.url); + details.requestURL = vAPI.punycodeURL(request.url); + details.requestHostname = µburi.hostnameFromURI(details.requestURL); details.requestType = tagNameToRequestTypeMap[request.tagName]; result = pageStore.filterRequest(details); if ( pageStore.boolFromResult(result) ) { @@ -379,9 +380,11 @@ var filterRequest = function(pageStore, details) { return; } var µburi = µb.URI; + details.pageHostname = vAPI.punycodeHostname(details.pageHostname); details.pageDomain = µburi.domainFromHostname(details.pageHostname); details.rootHostname = pageStore.rootHostname; details.rootDomain = pageStore.rootDomain; + details.requestURL = vAPI.punycodeURL(details.requestURL); details.requestHostname = µburi.hostnameFromURI(details.requestURL); details.requestType = tagNameToRequestTypeMap[details.tagName]; var result = pageStore.filterRequest(details); diff --git a/src/js/popup.js b/src/js/popup.js index 57a8f950d..a18b03c1e 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -139,7 +139,7 @@ var addDynamicFilterRow = function(des) { } row.descendants('[data-des]').attr('data-des', des); - row.descendants('span:nth-of-type(1)').text(des); + row.descendants('span:nth-of-type(1)').text(punycode.toUnicode(des)); var hnDetails = popupData.hostnameDict[des] || {}; diff --git a/src/popup.html b/src/popup.html index 6233f1610..9679abfdd 100644 --- a/src/popup.html +++ b/src/popup.html @@ -42,6 +42,7 @@
+