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 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 vAPI = self.vAPI;
// https://github.com/gorhill/uBlock/issues/456
// 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;
/******************************************************************************/
@ -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;
};
/******************************************************************************/
})();
/******************************************************************************/

View File

@ -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;
};
/******************************************************************************/
})();

View File

@ -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);

View File

@ -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] || {};

View File

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