Skip to content
Snippets Groups Projects
Commit a9bd2e19 authored by henry's avatar henry Committed by Pier Angelo Vendrame
Browse files

fixup! Bug 40209: Implement Basic Crypto Safety

Bug 42202: Migrate crypto safety strings to Fluent.
parent d43940bd
No related branches found
No related tags found
1 merge request!980Bug 42512: Rebased alpha onto Firefox 115.10.0esr
......@@ -20,17 +20,8 @@ ChromeUtils.defineModuleGetter(
"resource://gre/modules/TorDomainIsolator.jsm"
);
XPCOMUtils.defineLazyGetter(lazy, "cryptoSafetyBundle", () => {
return Services.strings.createBundle(
"chrome://browser/locale/cryptoSafetyPrompt.properties"
);
});
// en-US fallback in case a locale is missing a string.
XPCOMUtils.defineLazyGetter(lazy, "fallbackCryptoSafetyBundle", () => {
return Services.strings.createBundle(
"resource:///chrome/en-US/locale/browser/cryptoSafetyPrompt.properties"
);
ChromeUtils.defineLazyGetter(lazy, "CryptoStrings", function () {
return new Localization(["browser/tor-browser.ftl"]);
});
XPCOMUtils.defineLazyPreferenceGetter(
......@@ -40,26 +31,8 @@ XPCOMUtils.defineLazyPreferenceGetter(
true // Defaults to true.
);
/**
* Get a formatted string from the locale's bundle, or the en-US bundle if the
* string is missing.
*
* @param {string} name - The string's name.
* @param {string[]} [args] - Positional arguments to pass to the format string,
* or leave empty if none are needed.
*
* @returns {string} - The formatted string.
*/
function getString(name, args = []) {
try {
return lazy.cryptoSafetyBundle.formatStringFromName(name, args);
} catch {
return lazy.fallbackCryptoSafetyBundle.formatStringFromName(name, args);
}
}
class CryptoSafetyParent extends JSWindowActorParent {
receiveMessage(aMessage) {
async receiveMessage(aMessage) {
if (
!lazy.isCryptoSafetyEnabled ||
aMessage.name !== "CryptoSafety:CopiedText"
......@@ -72,14 +45,25 @@ class CryptoSafetyParent extends JSWindowActorParent {
address = `${address.substring(0, 32)}…`;
}
const [titleText, bodyText, reloadText, dismissText] =
await lazy.CryptoStrings.formatValues([
{ id: "crypto-safety-prompt-title" },
{
id: "crypto-safety-prompt-body",
args: { address, host: aMessage.data.host },
},
{ id: "crypto-safety-prompt-reload-button" },
{ id: "crypto-safety-prompt-dismiss-button" },
]);
const buttonPressed = Services.prompt.confirmEx(
this.browsingContext.topChromeWindow,
getString("cryptoSafetyPrompt.cryptoTitle"),
getString("cryptoSafetyPrompt.cryptoBody", [address, aMessage.data.host]),
titleText,
bodyText,
Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_0 +
Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_1,
getString("cryptoSafetyPrompt.primaryAction"),
getString("cryptoSafetyPrompt.secondaryAction"),
reloadText,
dismissText,
null,
null,
{}
......
# Copyright (c) 2022, The Tor Project, Inc.
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
cryptoSafetyPrompt.cryptoTitle=Cryptocurrency address copied from an insecure website
# LOCALIZATION NOTE:
# %1$S is the copied cryptocurrency address.
# %2$S is the website host.
cryptoSafetyPrompt.cryptoBody=The copied text (%1$S) appears to be a cryptocurrency address. Since the connection to %2$S is not secure, the address may have been modified and should not be trusted. You can try establishing a secure connection by reconnecting with a new circuit.
# LOCALIZATION NOTE: %S will be replaced with the cryptocurrency address.
cryptoSafetyPrompt.cryptoWarning=A cryptocurrency address (%S) has been copied from an insecure website. It could have been modified.
cryptoSafetyPrompt.whatCanHeading=What can you do about it?
cryptoSafetyPrompt.whatCanBody=You can try reconnecting with a new circuit to establish a secure connection, or accept the risk and dismiss this warning.
cryptoSafetyPrompt.learnMore=Learn more
cryptoSafetyPrompt.primaryAction=Reload Tab with a New Circuit
cryptoSafetyPrompt.primaryActionAccessKey=R
cryptoSafetyPrompt.secondaryAction=Dismiss Warning
cryptoSafetyPrompt.secondaryActionAccessKey=B
......@@ -33,5 +33,4 @@
locale/browser/safebrowsing/safebrowsing.properties (%chrome/browser/safebrowsing/safebrowsing.properties)
locale/browser/feeds/subscribe.properties (%chrome/browser/feeds/subscribe.properties)
locale/browser/syncSetup.properties (%chrome/browser/syncSetup.properties)
locale/browser/cryptoSafetyPrompt.properties (%chrome/browser/cryptoSafetyPrompt.properties)
% locale browser-region @AB_CD@ %locale/browser-region/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment