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
This commit is contained in:
Jonathan Kew 2020-04-23 10:04:18 +00:00
parent d0d3827cd2
commit db407a2c45

View File

@ -170,7 +170,19 @@ nsStaticAtom* nsLanguageAtomService::GetUncachedLanguageGroup(
}
}
} else {
// If the lang code can be parsed as BCP47, look up its (likely) script
// If the lang code can be parsed as BCP47, look up its (likely) script.
// https://bugzilla.mozilla.org/show_bug.cgi?id=1618034:
// First strip any private subtags that would cause Locale to reject the
// tag as non-wellformed.
nsACString::const_iterator start, end;
langStr.BeginReading(start);
langStr.EndReading(end);
if (FindInReadable(NS_LITERAL_CSTRING("-x-"), start, end)) {
// The substring we want ends at the beginning of the "-x-" subtag.
langStr.Truncate(start.get() - langStr.BeginReading());
}
Locale loc(langStr);
if (loc.IsWellFormed()) {
// Fill in script subtag if not present.