Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1510015 - Display IDN domain names properly in the storage access…
Browse files Browse the repository at this point in the history
… API doorhanger r=johannh

Differential Revision: https://phabricator.services.mozilla.com/D12984
  • Loading branch information
ehsan committed Nov 30, 2018
1 parent e3fcce2 commit 9085493
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions browser/modules/PermissionUI.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ ChromeUtils.defineModuleGetter(this, "PrivateBrowsingUtils",
ChromeUtils.defineModuleGetter(this, "URICountListener",
"resource:///modules/BrowserUsageTelemetry.jsm");

XPCOMUtils.defineLazyServiceGetter(this, "IDNService",
"@mozilla.org/network/idn-service;1", "nsIIDNService");

XPCOMUtils.defineLazyGetter(this, "gBrowserBundle", function() {
return Services.strings
.createBundle("chrome://browser/locale/browser.properties");
Expand Down Expand Up @@ -943,19 +946,32 @@ StorageAccessPermissionPrompt.prototype = {
return "storage-access-" + this.principal.origin;
},

prettifyHostPort(uri) {
try {
uri = Services.uriFixup.createExposableURI(uri);
} catch (e) {
// ignore, since we can't do anything better
}
let host = IDNService.convertToDisplayIDN(uri.host, {});
if (uri.port != -1) {
host += `:${uri.port}`;
}
return host;
},

get popupOptions() {
return {
displayURI: false,
name: this.principal.URI.hostPort,
secondName: this.topLevelPrincipal.URI.hostPort,
name: this.prettifyHostPort(this.principal.URI),
secondName: this.prettifyHostPort(this.topLevelPrincipal.URI),
};
},

onShown() {
let document = this.browser.ownerDocument;
let label =
gBrowserBundle.formatStringFromName("storageAccess.description.label",
[this.request.principal.URI.hostPort, "<>"], 2);
[this.prettifyHostPort(this.request.principal.URI), "<>"], 2);
let parts = label.split("<>");
if (parts.length == 1) {
parts.push("");
Expand Down

0 comments on commit 9085493

Please sign in to comment.