This is an automated email from the git hooks/post-receive script.
richard pushed a commit to branch tor-browser-91.9.0esr-11.5-1 in repository tor-browser.
The following commit(s) were added to refs/heads/tor-browser-91.9.0esr-11.5-1 by this push: new 65b1177a09f91 fixup! Bug 40309: Avoid using regional OS locales 65b1177a09f91 is described below
commit 65b1177a09f919d62f21d0b9ba35e165f4675a14 Author: Pier Angelo Vendrame pierov@torproject.org AuthorDate: Wed May 18 19:22:37 2022 +0200
fixup! Bug 40309: Avoid using regional OS locales
Avoid regional OS locales if the pref `intl.regional_prefs.use_os_locales` is false but RFP is enabled. --- intl/locale/LocaleService.cpp | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-)
diff --git a/intl/locale/LocaleService.cpp b/intl/locale/LocaleService.cpp index ac001ee98991c..10342c6024998 100644 --- a/intl/locale/LocaleService.cpp +++ b/intl/locale/LocaleService.cpp @@ -15,6 +15,7 @@ #include "mozilla/intl/OSPreferences.h" #include "nsDirectoryService.h" #include "nsDirectoryServiceDefs.h" +#include "nsContentUtils.h" #include "nsIObserverService.h" #include "nsStringEnumerator.h" #include "nsXULAppAPI.h" @@ -447,11 +448,36 @@ LocaleService::GetRegionalPrefsLocales(nsTArray<nsCString>& aRetVal) {
// If the user specified that they want to use OS Regional Preferences // locales, try to retrieve them and use. - if (useOSLocales) { - if (NS_SUCCEEDED( + if (useOSLocales && NS_SUCCEEDED( OSPreferences::GetInstance()->GetRegionalPrefsLocales(aRetVal))) { - return NS_OK; - } + return NS_OK; + } + if (useOSLocales || nsContentUtils::ShouldResistFingerprinting()) { + // If we fail to retrieve them, or we have RFP enabled, just return the app + // locales. + GetAppLocalesAsBCP47(aRetVal); + return NS_OK; + } + + // Otherwise, fetch OS Regional Preferences locales and compare the first one + // to the app locale. If the language subtag matches, we can safely use + // the OS Regional Preferences locale. + // + // This facilitates scenarios such as Firefox in "en-US" and User sets + // regional prefs to "en-GB". + nsAutoCString appLocale; + AutoTArray<nsCString, 10> regionalPrefsLocales; + LocaleService::GetInstance()->GetAppLocaleAsBCP47(appLocale); + + if (NS_FAILED(OSPreferences::GetInstance()->GetRegionalPrefsLocales( + regionalPrefsLocales))) { + GetAppLocalesAsBCP47(aRetVal); + return NS_OK; + } + + if (LocaleService::LanguagesMatch(appLocale, regionalPrefsLocales[0])) { + aRetVal = regionalPrefsLocales.Clone(); + return NS_OK; }
// Otherwise use the app locales.