Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit db407a2

Browse files
committed
Bug 1618034 - Strip private subtags in nsLanguageAtomService::GetUncachedLanguageGroup so that we can parse the standard subtags and use the proper font prefs. r=zbraniecki
Differential Revision: https://phabricator.services.mozilla.com/D72050
1 parent d0d3827 commit db407a2

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

intl/locale/nsLanguageAtomService.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,19 @@ nsStaticAtom* nsLanguageAtomService::GetUncachedLanguageGroup(
170170
}
171171
}
172172
} else {
173-
// If the lang code can be parsed as BCP47, look up its (likely) script
173+
// If the lang code can be parsed as BCP47, look up its (likely) script.
174+
175+
// https://bugzilla.mozilla.org/show_bug.cgi?id=1618034:
176+
// First strip any private subtags that would cause Locale to reject the
177+
// tag as non-wellformed.
178+
nsACString::const_iterator start, end;
179+
langStr.BeginReading(start);
180+
langStr.EndReading(end);
181+
if (FindInReadable(NS_LITERAL_CSTRING("-x-"), start, end)) {
182+
// The substring we want ends at the beginning of the "-x-" subtag.
183+
langStr.Truncate(start.get() - langStr.BeginReading());
184+
}
185+
174186
Locale loc(langStr);
175187
if (loc.IsWellFormed()) {
176188
// Fill in script subtag if not present.

0 commit comments

Comments
 (0)