ma1 pushed to branch base-browser-115.5.0esr-13.5-1 at The Tor Project / Applications / Tor Browser
Commits: 4098cfce by hackademix at 2023-11-22T23:14:15+01:00 Bug 42288: Allow language spoofing in status messages.
- - - - -
8 changed files:
- browser/installer/package-manifest.in - dom/locales/moz.build - dom/xslt/xslt/txMozillaXSLTProcessor.cpp - dom/xslt/xslt/txXSLTMsgsURL.h - intl/strres/nsIStringBundle.idl - intl/strres/nsStringBundle.cpp - mobile/android/installer/package-manifest.in - uriloader/base/nsDocLoader.cpp
Changes:
===================================== browser/installer/package-manifest.in ===================================== @@ -318,6 +318,7 @@ @RESPATH@/res/locale/layout/HtmlForm.properties @RESPATH@/res/locale/layout/MediaDocument.properties @RESPATH@/res/locale/layout/xmlparser.properties +@RESPATH@/res/locale/xslt/xslt.properties @RESPATH@/res/locale/dom/dom.properties #ifdef XP_MACOSX @RESPATH@/res/MainMenu.nib/
===================================== dom/locales/moz.build ===================================== @@ -57,6 +57,10 @@ RESOURCE_FILES.locale.layout += [ "en-US/chrome/layout/xmlparser.properties", ]
+RESOURCE_FILES.locale.xslt += [ + "en-US/chrome/xslt/xslt.properties", +] + RESOURCE_FILES.locale.dom += [ "en-US/chrome/dom/dom.properties", ]
===================================== dom/xslt/xslt/txMozillaXSLTProcessor.cpp ===================================== @@ -942,11 +942,17 @@ void txMozillaXSLTProcessor::reportError(nsresult aResult, mozilla::components::StringBundle::Service(); if (sbs) { nsString errorText; - sbs->FormatStatusMessage(aResult, u"", errorText); + bool spoofLocale = nsContentUtils::SpoofLocaleEnglish(); + if (spoofLocale && mSource) { + Document* sourceDoc = mSource->OwnerDoc(); + spoofLocale = !(sourceDoc && sourceDoc->AllowsL10n()); + } + sbs->FormatStatusMessage(aResult, u"", spoofLocale, errorText);
nsAutoString errorMessage; nsCOMPtr<nsIStringBundle> bundle; - sbs->CreateBundle(XSLT_MSGS_URL, getter_AddRefs(bundle)); + sbs->CreateBundle(spoofLocale ? XSLT_MSGS_URL_en_US : XSLT_MSGS_URL, + getter_AddRefs(bundle));
if (bundle) { AutoTArray<nsString, 1> error = {errorText};
===================================== dom/xslt/xslt/txXSLTMsgsURL.h ===================================== @@ -7,5 +7,6 @@ #define DOM_XSLT_XSLT_TXXSLTMSGSURL_H_
#define XSLT_MSGS_URL "chrome://global/locale/xslt/xslt.properties" +#define XSLT_MSGS_URL_en_US "resource://gre/res/locale/xslt/xslt.properties"
#endif // DOM_XSLT_XSLT_TXXSLTMSGSURL_H_
===================================== intl/strres/nsIStringBundle.idl ===================================== @@ -86,9 +86,13 @@ interface nsIStringBundleService : nsISupports * used in the string lookup process. * @param aStatusArg - The status message argument(s). Multiple arguments * can be separated by newline ('\n') characters. + * @param aSpoofLocale - If true (default is false), forces the en-US + locale on content-accessible messages (XSLT errors so far). * @return the formatted message */ - AString formatStatusMessage(in nsresult aStatus, in wstring aStatusArg); + AString formatStatusMessage(in nsresult aStatus, + in wstring aStatusArg, + [optional] in boolean aSpoofLocale);
/** * flushes the string bundle cache - useful when the locale changes or
===================================== intl/strres/nsStringBundle.cpp ===================================== @@ -977,6 +977,7 @@ nsresult nsStringBundleService::FormatWithBundle( NS_IMETHODIMP nsStringBundleService::FormatStatusMessage(nsresult aStatus, const char16_t* aStatusArg, + bool aSpoofLocale, nsAString& result) { uint32_t i, argCount = 0; nsCOMPtr<nsIStringBundle> bundle; @@ -1012,7 +1013,8 @@ nsStringBundleService::FormatStatusMessage(nsresult aStatus,
switch (NS_ERROR_GET_MODULE(aStatus)) { case NS_ERROR_MODULE_XSLT: - getStringBundle(XSLT_MSGS_URL, getter_AddRefs(bundle)); + getStringBundle(aSpoofLocale ? XSLT_MSGS_URL_en_US : XSLT_MSGS_URL, + getter_AddRefs(bundle)); break; case NS_ERROR_MODULE_NETWORK: getStringBundle(NECKO_MSGS_URL, getter_AddRefs(bundle));
===================================== mobile/android/installer/package-manifest.in ===================================== @@ -181,6 +181,7 @@ @BINPATH@/res/locale/layout/HtmlForm.properties @BINPATH@/res/locale/layout/MediaDocument.properties @BINPATH@/res/locale/layout/xmlparser.properties +@BINPATH@/res/locale/xslt/xslt.properties @BINPATH@/res/locale/dom/dom.properties
#ifndef MOZ_ANDROID_EXCLUDE_FONTS
===================================== uriloader/base/nsDocLoader.cpp ===================================== @@ -1230,7 +1230,7 @@ NS_IMETHODIMP nsDocLoader::OnStatus(nsIRequest* aRequest, nsresult aStatus, mozilla::components::StringBundle::Service(); if (!sbs) return NS_ERROR_FAILURE; nsAutoString msg; - nsresult rv = sbs->FormatStatusMessage(aStatus, aStatusArg, msg); + nsresult rv = sbs->FormatStatusMessage(aStatus, aStatusArg, false, msg); if (NS_FAILED(rv)) return rv;
// Keep around the message. In case a request finishes, we need to make sure
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/4098cfce...