Closed Bug 1785807 Opened 2 years ago Closed 2 years ago

intl.accept_languages is not in canonical form on Android, but all lower case

Categories

(GeckoView :: General, defect, P3)

All
Android
defect

Tracking

(firefox109 fixed)

RESOLVED FIXED
109 Branch
Tracking Status
firefox109 --- fixed

People

(Reporter: robwu, Assigned: zmckenney)

References

(Blocks 1 open bug)

Details

(Keywords: good-first-bug)

Attachments

(1 file)

In https://phabricator.services.mozilla.com/D151606?id=616048#inline-852560, we observed that the i18n.getAcceptLanguages extension API returned en-us (lowercase us instead of en-US, en as on desktop).

It looks like the missing fallback , en seems to be addressed in bug 1765375.

Still, the en-us part being full-lowercase is not ideal. It looks like the implementation in GeckoViewStartup.jsm explicitly turns everything to lower case. This should be <lowercase>-<uppercase> instead.

The Accept-Language header doesn't rely on the exact casing, because the pref value is processed and turned into a canonical format (also with q-values added).

For reference, this is the full call stack that I traced to get to the root cause of the observed issue:

... but on Android (i.e. GeckoView), all of that is overridden at https://searchfox.org/mozilla-central/rev/db4b1d66c4b409bdbce43f3f3498401f5303d961/mobile/android/components/geckoview/GeckoViewStartup.jsm#253-266
called via https://searchfox.org/mozilla-central/rev/db4b1d66c4b409bdbce43f3f3498401f5303d961/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java#786
... which sets everything to lowercase.

We'll also need to stop lowercasing the locale identifiers returned by the OS:

https://searchfox.org/mozilla-central/rev/db4b1d66c4b409bdbce43f3f3498401f5303d961/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java#789-795

This code lowercases the locale identifiers because it wants to detect duplicate locale identifiers (that may have different capitalization). If we want to keep that check, then this function will need to build two lists of locale identifiers:

  • the list of lowercased locale identifiers to detect duplicate locale identifiers (that may have different capitalization)
  • a list of the locale identifiers with their original capitalization (but still no duplicates) that the function returns at the end

This might be a good first bug because the fix is contained in only one function.

Severity: -- → S4
Keywords: good-first-bug
Priority: -- → P3
Assignee: nobody → zmckenney
Attachment #9304637 - Attachment description: Bug 1785807 - Added lowercase Hashset for duplication check when adding system default languages to computed accepted languages. Updated test to proper format. r=cpeterson → Bug 1785807 - Refactored to HashMap for duplication check when adding system default languages to computed accepted languages. Updated js test to proper format. Added tests for locale format and duplication. r=cpeterson
Attachment #9304637 - Attachment description: Bug 1785807 - Refactored to HashMap for duplication check when adding system default languages to computed accepted languages. Updated js test to proper format. Added tests for locale format and duplication. r=cpeterson → Bug 1785807 - Added duplication check and proper capitilization for computeAcceptLanguages. r=cpeterson
Pushed by istorozhko@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/08762d1adaff Added duplication check and proper capitilization for computeAcceptLanguages. r=geckoview-reviewers,extension-reviewers,calu,owlish,robwu
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 109 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: