Opened 2 years ago

Closed 2 years ago

Last modified 22 months ago

#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 igt0)

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) {

        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);

        let appLocale = this.getUALocalePref();

        this.computeAcceptLanguages(languageTag, appLocale);

        // Rebuild strings, in case we're mirroring OS locale.

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) {

    if (appLocale && appLocale != osLocale) {

    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 2 years ago by igt0

Description: modified (diff)

comment:2 Changed 2 years ago by igt0

Parent ID: #25703

comment:3 Changed 2 years ago by igt0

It leaks even when the user doesn't change the OS locale.

comment:4 Changed 2 years ago by igt0

Mozilla bug used to track this bug:

comment:5 Changed 2 years ago by igt0

It was merged

However It will not be available in the FF61, so we will need to cherry pick it.

comment:6 Changed 2 years ago by gk

Keywords: TorBrowserTeam201807R added
Status: newneeds_review

bug_26018 ( has the backport in question. It applied cleanly, please have a look.

comment:7 in reply to:  6 Changed 2 years ago by igt0


Replying to gk:

bug_26018 ( has the backport in question. It applied cleanly, please have a look.

comment:8 Changed 2 years ago by gk

Resolution: fixed
Status: needs_reviewclosed

Fixed with commit d352f450f3edd120df9b7ab973db45069ef22bb2 on tor-browser-60.1.0esr-8.0-1.

comment:9 Changed 22 months ago by gk

Sponsor: Sponsor8

Sponsor8 in July 2018.

Note: See TracTickets for help on using tickets.