richard pushed to branch tor-browser-115.9.0esr-13.5-1 at The Tor Project / Applications / Tor Browser
Commits:
- 
3ddbe28a
by Henry Wilkes at 2024-04-08T18:58:55+00:00
- 
58d32687
by Henry Wilkes at 2024-04-08T18:58:55+00:00
- 
bb6f56ad
by Henry Wilkes at 2024-04-08T18:58:55+00:00
5 changed files:
- browser/actors/CryptoSafetyParent.jsm
- browser/locales/en-US/browser/tor-browser.ftl
- − browser/locales/en-US/chrome/browser/cryptoSafetyPrompt.properties
- browser/locales/jar.mn
- + tools/torbrowser/l10n/migrations/bug-42202-crypto-safety.py
Changes:
| ... | ... | @@ -20,17 +20,8 @@ ChromeUtils.defineModuleGetter( | 
| 20 | 20 |    "resource://gre/modules/TorDomainIsolator.jsm"
 | 
| 21 | 21 |  );
 | 
| 22 | 22 | |
| 23 | -XPCOMUtils.defineLazyGetter(lazy, "cryptoSafetyBundle", () => {
 | |
| 24 | -  return Services.strings.createBundle(
 | |
| 25 | -    "chrome://browser/locale/cryptoSafetyPrompt.properties"
 | |
| 26 | -  );
 | |
| 27 | -});
 | |
| 28 | - | |
| 29 | -// en-US fallback in case a locale is missing a string.
 | |
| 30 | -XPCOMUtils.defineLazyGetter(lazy, "fallbackCryptoSafetyBundle", () => {
 | |
| 31 | -  return Services.strings.createBundle(
 | |
| 32 | -    "resource:///chrome/en-US/locale/browser/cryptoSafetyPrompt.properties"
 | |
| 33 | -  );
 | |
| 23 | +ChromeUtils.defineLazyGetter(lazy, "CryptoStrings", function () {
 | |
| 24 | +  return new Localization(["browser/tor-browser.ftl"]);
 | |
| 34 | 25 |  });
 | 
| 35 | 26 | |
| 36 | 27 |  XPCOMUtils.defineLazyPreferenceGetter(
 | 
| ... | ... | @@ -40,26 +31,8 @@ XPCOMUtils.defineLazyPreferenceGetter( | 
| 40 | 31 |    true // Defaults to true.
 | 
| 41 | 32 |  );
 | 
| 42 | 33 | |
| 43 | -/**
 | |
| 44 | - * Get a formatted string from the locale's bundle, or the en-US bundle if the
 | |
| 45 | - * string is missing.
 | |
| 46 | - *
 | |
| 47 | - * @param {string} name - The string's name.
 | |
| 48 | - * @param {string[]} [args] - Positional arguments to pass to the format string,
 | |
| 49 | - *   or leave empty if none are needed.
 | |
| 50 | - *
 | |
| 51 | - * @returns {string} - The formatted string.
 | |
| 52 | - */
 | |
| 53 | -function getString(name, args = []) {
 | |
| 54 | -  try {
 | |
| 55 | -    return lazy.cryptoSafetyBundle.formatStringFromName(name, args);
 | |
| 56 | -  } catch {
 | |
| 57 | -    return lazy.fallbackCryptoSafetyBundle.formatStringFromName(name, args);
 | |
| 58 | -  }
 | |
| 59 | -}
 | |
| 60 | - | |
| 61 | 34 |  class CryptoSafetyParent extends JSWindowActorParent {
 | 
| 62 | -  receiveMessage(aMessage) {
 | |
| 35 | +  async receiveMessage(aMessage) {
 | |
| 63 | 36 |      if (
 | 
| 64 | 37 |        !lazy.isCryptoSafetyEnabled ||
 | 
| 65 | 38 |        aMessage.name !== "CryptoSafety:CopiedText"
 | 
| ... | ... | @@ -72,14 +45,25 @@ class CryptoSafetyParent extends JSWindowActorParent { | 
| 72 | 45 |        address = `${address.substring(0, 32)}…`;
 | 
| 73 | 46 |      }
 | 
| 74 | 47 | |
| 48 | +    const [titleText, bodyText, reloadText, dismissText] =
 | |
| 49 | +      await lazy.CryptoStrings.formatValues([
 | |
| 50 | +        { id: "crypto-safety-prompt-title" },
 | |
| 51 | +        {
 | |
| 52 | +          id: "crypto-safety-prompt-body",
 | |
| 53 | +          args: { address, host: aMessage.data.host },
 | |
| 54 | +        },
 | |
| 55 | +        { id: "crypto-safety-prompt-reload-button" },
 | |
| 56 | +        { id: "crypto-safety-prompt-dismiss-button" },
 | |
| 57 | +      ]);
 | |
| 58 | + | |
| 75 | 59 |      const buttonPressed = Services.prompt.confirmEx(
 | 
| 76 | 60 |        this.browsingContext.topChromeWindow,
 | 
| 77 | -      getString("cryptoSafetyPrompt.cryptoTitle"),
 | |
| 78 | -      getString("cryptoSafetyPrompt.cryptoBody", [address, aMessage.data.host]),
 | |
| 61 | +      titleText,
 | |
| 62 | +      bodyText,
 | |
| 79 | 63 |        Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_0 +
 | 
| 80 | 64 |          Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_1,
 | 
| 81 | -      getString("cryptoSafetyPrompt.primaryAction"),
 | |
| 82 | -      getString("cryptoSafetyPrompt.secondaryAction"),
 | |
| 65 | +      reloadText,
 | |
| 66 | +      dismissText,
 | |
| 83 | 67 |        null,
 | 
| 84 | 68 |        null,
 | 
| 85 | 69 |        {}
 | 
| ... | ... | @@ -382,3 +382,12 @@ tor-circuit-panel-new-button = New Tor circuit for this site | 
| 382 | 382 |  tor-circuit-panel-new-button-description-guard = Your guard node may not change
 | 
| 383 | 383 |  # Shown when the first node in the circuit is a bridge node.
 | 
| 384 | 384 |  tor-circuit-panel-new-button-description-bridge = Your bridge may not change
 | 
| 385 | + | |
| 386 | +## This dialog is shown when copying a suspected cryptocurrency address from a plain HTTP website.
 | |
| 387 | + | |
| 388 | +crypto-safety-prompt-title = Cryptocurrency address copied from an insecure website
 | |
| 389 | +# $address (String) - The cryptocurrency address, possibly truncated.
 | |
| 390 | +# $host (String) - The website host the address was copied from.
 | |
| 391 | +crypto-safety-prompt-body = The copied text ({ $address }) appears to be a cryptocurrency address. Since the connection to { $host } 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.
 | |
| 392 | +crypto-safety-prompt-reload-button = Reload Tab with a New Circuit
 | |
| 393 | +crypto-safety-prompt-dismiss-button = Dismiss Warning | 
| 1 | -# Copyright (c) 2022, The Tor Project, Inc.
 | |
| 2 | -# This Source Code Form is subject to the terms of the Mozilla Public
 | |
| 3 | -# License, v. 2.0. If a copy of the MPL was not distributed with this
 | |
| 4 | -# file, You can obtain one at http://mozilla.org/MPL/2.0/.
 | |
| 5 | - | |
| 6 | -cryptoSafetyPrompt.cryptoTitle=Cryptocurrency address copied from an insecure website
 | |
| 7 | -# LOCALIZATION NOTE:
 | |
| 8 | -# %1$S is the copied cryptocurrency address.
 | |
| 9 | -# %2$S is the website host.
 | |
| 10 | -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.
 | |
| 11 | -# LOCALIZATION NOTE: %S will be replaced with the cryptocurrency address.
 | |
| 12 | -cryptoSafetyPrompt.cryptoWarning=A cryptocurrency address (%S) has been copied from an insecure website. It could have been modified.
 | |
| 13 | -cryptoSafetyPrompt.whatCanHeading=What can you do about it?
 | |
| 14 | -cryptoSafetyPrompt.whatCanBody=You can try reconnecting with a new circuit to establish a secure connection, or accept the risk and dismiss this warning.
 | |
| 15 | -cryptoSafetyPrompt.learnMore=Learn more
 | |
| 16 | -cryptoSafetyPrompt.primaryAction=Reload Tab with a New Circuit
 | |
| 17 | -cryptoSafetyPrompt.primaryActionAccessKey=R
 | |
| 18 | -cryptoSafetyPrompt.secondaryAction=Dismiss Warning
 | |
| 19 | -cryptoSafetyPrompt.secondaryActionAccessKey=B | 
| ... | ... | @@ -33,5 +33,4 @@ | 
| 33 | 33 |      locale/browser/safebrowsing/safebrowsing.properties   (%chrome/browser/safebrowsing/safebrowsing.properties)
 | 
| 34 | 34 |      locale/browser/feeds/subscribe.properties       (%chrome/browser/feeds/subscribe.properties)
 | 
| 35 | 35 |      locale/browser/syncSetup.properties         (%chrome/browser/syncSetup.properties)
 | 
| 36 | -    locale/browser/cryptoSafetyPrompt.properties    (%chrome/browser/cryptoSafetyPrompt.properties)
 | |
| 37 | 36 |  % locale browser-region @AB_CD@ %locale/browser-region/ | 
| 1 | +import fluent.syntax.ast as FTL
 | |
| 2 | +from fluent.migrate.helpers import VARIABLE_REFERENCE, transforms_from
 | |
| 3 | +from fluent.migrate.transforms import REPLACE
 | |
| 4 | + | |
| 5 | + | |
| 6 | +def migrate(ctx):
 | |
| 7 | +    legacy_path = "cryptoSafetyPrompt.properties"
 | |
| 8 | + | |
| 9 | +    ctx.add_transforms(
 | |
| 10 | +        "tor-browser.ftl",
 | |
| 11 | +        "tor-browser.ftl",
 | |
| 12 | +        transforms_from(
 | |
| 13 | +            """
 | |
| 14 | +crypto-safety-prompt-title = { COPY(path, "cryptoSafetyPrompt.cryptoTitle") }
 | |
| 15 | +crypto-safety-prompt-reload-button = { COPY(path, "cryptoSafetyPrompt.primaryAction") }
 | |
| 16 | +crypto-safety-prompt-dismiss-button = { COPY(path, "cryptoSafetyPrompt.secondaryAction") }
 | |
| 17 | +""",
 | |
| 18 | +            path=legacy_path,
 | |
| 19 | +        )
 | |
| 20 | +        + [
 | |
| 21 | +            # Replace "%1$S" and "%2$S" with "{ $address }" and "{ $host }"
 | |
| 22 | +            FTL.Message(
 | |
| 23 | +                id=FTL.Identifier("crypto-safety-prompt-body"),
 | |
| 24 | +                value=REPLACE(
 | |
| 25 | +                    legacy_path,
 | |
| 26 | +                    "cryptoSafetyPrompt.cryptoBody",
 | |
| 27 | +                    {
 | |
| 28 | +                        "%1$S": VARIABLE_REFERENCE("address"),
 | |
| 29 | +                        "%2$S": VARIABLE_REFERENCE("host"),
 | |
| 30 | +                    },
 | |
| 31 | +                ),
 | |
| 32 | +            ),
 | |
| 33 | +        ],
 | |
| 34 | +    ) |