#26018 closed defect (fixed)
intl.accept_languages changes when the user changes their OS language
Reported by: | igt0 | Owned by: | tbb-team |
---|---|---|---|
Priority: | Medium | Milestone: | |
Component: | Applications/Tor Browser | Version: | |
Severity: | Normal | Keywords: | tbb-mobile, TorBrowserTeam201807R |
Cc: | sysrqb, gk | Actual Points: | |
Parent ID: | #25703 | Points: | |
Reviewer: | Sponsor: | Sponsor8 |
Description (last modified by )
When the OS language changes, FF mobile updates the intl.locale.os and intl.accept_languages preferences.
case "Locale:OS": { // We know the system locale. We use this for generating Accept-Language headers. let languageTag = data.languageTag; console.log("Locale:OS: " + languageTag); let currentOSLocale = this.getOSLocalePref(); if (currentOSLocale == languageTag) { break; } console.log("New OS locale."); // Ensure that this choice is immediately persisted, because // Gecko won't be told again if it forgets. Services.prefs.setCharPref("intl.locale.os", languageTag); Services.prefs.savePrefFile(null); let appLocale = this.getUALocalePref(); this.computeAcceptLanguages(languageTag, appLocale); // Rebuild strings, in case we're mirroring OS locale. Strings.flush(); break; }
the method *computeAcceptLanguages* is the one responsible to keep the intl.accept_languages up to date.
computeAcceptLanguages(osLocale, appLocale) { let defaultBranch = Services.prefs.getDefaultBranch(null); let defaultAccept = defaultBranch.getComplexValue("intl.accept_languages", Ci.nsIPrefLocalizedString).data; console.log("Default intl.accept_languages = " + defaultAccept); // A guard for potential breakage. Bug 438031. // This should not be necessary, because we're reading from the default branch, // but better safe than sorry. if (defaultAccept && defaultAccept.startsWith("chrome://")) { defaultAccept = null; } else { // Ensure lowercase everywhere so we can compare. defaultAccept = defaultAccept.toLowerCase(); } if (appLocale) { appLocale = appLocale.toLowerCase(); } if (osLocale) { osLocale = osLocale.toLowerCase(); } // Eliminate values if they're present in the default. let chosen; if (defaultAccept) { // intl.accept_languages is a comma-separated list, with no q-value params. Those // are added when the header is generated. chosen = defaultAccept.split(",") .map((x) => x.trim()) .filter((x) => (x != appLocale && x != osLocale)); } else { chosen = []; } if (osLocale) { chosen.unshift(osLocale); } if (appLocale && appLocale != osLocale) { chosen.unshift(appLocale); } let result = chosen.join(","); console.log("Setting intl.accept_languages to " + result); this.setLocalizedPref("intl.accept_languages", result); },
Child Tickets
Change History (9)
comment:1 Changed 20 months ago by
Description: | modified (diff) |
---|
comment:2 Changed 20 months ago by
Parent ID: | → #25703 |
---|
comment:3 Changed 20 months ago by
comment:4 Changed 20 months ago by
Mozilla bug used to track this bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1459089
comment:5 Changed 19 months ago by
It was merged https://hg.mozilla.org/mozilla-central/rev/a25b2c7238f4
However It will not be available in the FF61, so we will need to cherry pick it.
comment:6 follow-up: 7 Changed 17 months ago by
Keywords: | TorBrowserTeam201807R added |
---|---|
Status: | new → needs_review |
bug_26018
(https://gitweb.torproject.org/user/gk/tor-browser.git/commit/?h=bug_26018&id=eb9f502a3a5f1d2f8780f516aaa9a2290d62276e) has the backport in question. It applied cleanly, please have a look.
comment:7 Changed 17 months ago by
LGTM
Replying to gk:
bug_26018
(https://gitweb.torproject.org/user/gk/tor-browser.git/commit/?h=bug_26018&id=eb9f502a3a5f1d2f8780f516aaa9a2290d62276e) has the backport in question. It applied cleanly, please have a look.
comment:8 Changed 17 months ago by
Resolution: | → fixed |
---|---|
Status: | needs_review → closed |
Fixed with commit d352f450f3edd120df9b7ab973db45069ef22bb2 on tor-browser-60.1.0esr-8.0-1
.
It leaks even when the user doesn't change the OS locale.