this fixes one part of #498

This commit is contained in:
gorhill 2015-01-14 17:45:55 -05:00
parent 511b700517
commit ee01803419
7 changed files with 54 additions and 19 deletions

View File

@ -31,9 +31,8 @@
/******************************************************************************/ /******************************************************************************/
self.vAPI = self.vAPI || {}; var vAPI = self.vAPI = self.vAPI || {};
var vAPI = self.vAPI;
var chrome = self.chrome; var chrome = self.chrome;
var manifest = chrome.runtime.getManifest(); var manifest = chrome.runtime.getManifest();
@ -470,6 +469,16 @@ vAPI.onLoadAllCompleted = function() {
/******************************************************************************/ /******************************************************************************/
vAPI.punycodeHostname = function(hostname) {
return hostname;
};
vAPI.punycodeURL = function(url) {
return url;
};
/******************************************************************************/
})(); })();
/******************************************************************************/ /******************************************************************************/

View File

@ -31,10 +31,9 @@
/******************************************************************************/ /******************************************************************************/
self.vAPI = self.vAPI || {}; var vAPI = self.vAPI = self.vAPI || {};
var chrome = self.chrome; var chrome = self.chrome;
var vAPI = self.vAPI;
// https://github.com/gorhill/uBlock/issues/456 // https://github.com/gorhill/uBlock/issues/456
// Already injected? // Already injected?

View File

@ -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; vAPI.firefox = true;
/******************************************************************************/ /******************************************************************************/
@ -302,16 +303,16 @@ var tabsProgressListener = {
var tabId = vAPI.tabs.getTabId(browser); var tabId = vAPI.tabs.getTabId(browser);
if ( flags & 1 ) { if ( flags & 1 ) {
vAPI.tabs.onUpdated(tabId, {url: location.spec}, { vAPI.tabs.onUpdated(tabId, {url: location.asciiSpec}, {
frameId: 0, frameId: 0,
tabId: tabId, tabId: tabId,
url: browser.currentURI.spec url: browser.currentURI.asciiSpec
}); });
} else if ( location.scheme === 'http' || location.scheme === 'https' ) { } else if ( location.scheme === 'http' || location.scheme === 'https' ) {
vAPI.tabs.onNavigation({ vAPI.tabs.onNavigation({
frameId: 0, frameId: 0,
tabId: tabId, tabId: tabId,
url: location.spec url: location.asciiSpec
}); });
} }
} }
@ -427,7 +428,7 @@ vAPI.tabs.get = function(tabId, callback) {
index: gBrowser.browsers.indexOf(browser), index: gBrowser.browsers.indexOf(browser),
windowId: windows.indexOf(browser.ownerDocument.defaultView), windowId: windows.indexOf(browser.ownerDocument.defaultView),
active: tab === gBrowser.selectedTab, active: tab === gBrowser.selectedTab,
url: browser.currentURI.spec, url: browser.currentURI.asciiSpec,
title: tab.label title: tab.label
}); });
}; };
@ -496,7 +497,7 @@ vAPI.tabs.open = function(details) {
for ( tab of tabs ) { for ( tab of tabs ) {
var browser = tab.linkedBrowser; var browser = tab.linkedBrowser;
if ( browser.currentURI.spec.replace(rgxHash, '') === url ) { if ( browser.currentURI.asciiSpec.replace(rgxHash, '') === url ) {
browser.ownerDocument.defaultView.gBrowser.selectedTab = tab; browser.ownerDocument.defaultView.gBrowser.selectedTab = tab;
return; return;
} }
@ -863,7 +864,7 @@ var httpObserver = {
var result = vAPI.tabs.onPopup({ var result = vAPI.tabs.onPopup({
tabId: tabId, tabId: tabId,
sourceTabId: sourceTabId, sourceTabId: sourceTabId,
url: URI.spec url: URI.asciiSpec
}); });
return result === true; return result === true;
@ -878,7 +879,7 @@ var httpObserver = {
} }
var result = onBeforeRequest.callback({ var result = onBeforeRequest.callback({
url: channel.URI.spec, url: channel.URI.asciiSpec,
type: type, type: type,
tabId: details.tabId, tabId: details.tabId,
frameId: details.frameId, frameId: details.frameId,
@ -940,7 +941,7 @@ var httpObserver = {
} }
result = vAPI.net.onHeadersReceived.callback({ result = vAPI.net.onHeadersReceived.callback({
url: URI.spec, url: URI.asciiSpec,
tabId: channelData[1], tabId: channelData[1],
parentFrameId: -1, parentFrameId: -1,
responseHeaders: result ? [{name: topic, value: result}] : [] responseHeaders: result ? [{name: topic, value: result}] : []
@ -978,7 +979,7 @@ var httpObserver = {
var tabURI = tab.linkedBrowser.currentURI; var tabURI = tab.linkedBrowser.currentURI;
// Not the best approach // Not the best approach
if ( tabURI.spec === this.lastRequest.openerURL ) { if ( tabURI.asciiSpec === this.lastRequest.openerURL ) {
sourceTabId = vAPI.tabs.getTabId(tab); sourceTabId = vAPI.tabs.getTabId(tab);
break; break;
} }
@ -1422,7 +1423,7 @@ vAPI.contextMenu.create = function(details, callback) {
callback(details, { callback(details, {
id: vAPI.tabs.getTabId(gContextMenu.browser), 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;
};
/******************************************************************************/
})(); })();
/******************************************************************************/ /******************************************************************************/

View File

@ -31,7 +31,8 @@
/******************************************************************************/ /******************************************************************************/
self.vAPI = self.vAPI || {}; var vAPI = self.vAPI = self.vAPI || {};
vAPI.safari = true; vAPI.safari = true;
/******************************************************************************/ /******************************************************************************/
@ -796,4 +797,14 @@ vAPI.onLoadAllCompleted = function() {
/******************************************************************************/ /******************************************************************************/
vAPI.punycodeHostname = function(hostname) {
return hostname;
};
vAPI.punycodeURL = function(url) {
return url;
};
/******************************************************************************/
})(); })();

View File

@ -342,6 +342,7 @@ var filterRequests = function(pageStore, details) {
var µburi = µb.URI; var µburi = µb.URI;
// Create evaluation context // Create evaluation context
details.pageHostname = vAPI.punycodeHostname(details.pageHostname);
details.pageDomain = µburi.domainFromHostname(details.pageHostname); details.pageDomain = µburi.domainFromHostname(details.pageHostname);
details.rootHostname = pageStore.rootHostname; details.rootHostname = pageStore.rootHostname;
details.rootDomain = pageStore.rootDomain; details.rootDomain = pageStore.rootDomain;
@ -356,8 +357,8 @@ var filterRequests = function(pageStore, details) {
if ( tagNameToRequestTypeMap.hasOwnProperty(request.tagName) === false ) { if ( tagNameToRequestTypeMap.hasOwnProperty(request.tagName) === false ) {
continue; continue;
} }
details.requestURL = request.url; details.requestURL = vAPI.punycodeURL(request.url);
details.requestHostname = µburi.hostnameFromURI(request.url); details.requestHostname = µburi.hostnameFromURI(details.requestURL);
details.requestType = tagNameToRequestTypeMap[request.tagName]; details.requestType = tagNameToRequestTypeMap[request.tagName];
result = pageStore.filterRequest(details); result = pageStore.filterRequest(details);
if ( pageStore.boolFromResult(result) ) { if ( pageStore.boolFromResult(result) ) {
@ -379,9 +380,11 @@ var filterRequest = function(pageStore, details) {
return; return;
} }
var µburi = µb.URI; var µburi = µb.URI;
details.pageHostname = vAPI.punycodeHostname(details.pageHostname);
details.pageDomain = µburi.domainFromHostname(details.pageHostname); details.pageDomain = µburi.domainFromHostname(details.pageHostname);
details.rootHostname = pageStore.rootHostname; details.rootHostname = pageStore.rootHostname;
details.rootDomain = pageStore.rootDomain; details.rootDomain = pageStore.rootDomain;
details.requestURL = vAPI.punycodeURL(details.requestURL);
details.requestHostname = µburi.hostnameFromURI(details.requestURL); details.requestHostname = µburi.hostnameFromURI(details.requestURL);
details.requestType = tagNameToRequestTypeMap[details.tagName]; details.requestType = tagNameToRequestTypeMap[details.tagName];
var result = pageStore.filterRequest(details); var result = pageStore.filterRequest(details);

View File

@ -139,7 +139,7 @@ var addDynamicFilterRow = function(des) {
} }
row.descendants('[data-des]').attr('data-des', 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] || {}; var hnDetails = popupData.hostnameDict[des] || {};

View File

@ -42,6 +42,7 @@
<div id="hotspotTip"></div> <div id="hotspotTip"></div>
</div> </div>
<script src="lib/punycode.min.js"></script>
<script src="js/vapi-common.js"></script> <script src="js/vapi-common.js"></script>
<script src="js/vapi-client.js"></script> <script src="js/vapi-client.js"></script>
<script src="js/vapi-popup.js"></script> <script src="js/vapi-popup.js"></script>