Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 65cc85bbf51038440464ee51b3476412c2466719
https://github.com/WebKit/WebKit/commit/65cc85bbf51038440464ee51b3476412c2466719
Author: Yusuke Suzuki <[email protected]>
Date: 2026-03-05 (Thu, 05 Mar 2026)
Changed paths:
M Source/JavaScriptCore/runtime/IntlLocale.cpp
M Source/JavaScriptCore/runtime/IntlLocale.h
M Source/JavaScriptCore/runtime/IntlObject.cpp
M Source/JavaScriptCore/runtime/IntlObject.h
Log Message:
-----------
[JSC] Tolerant againt non-Unicode BCP 47 extensions + maximize / minimize
https://bugs.webkit.org/show_bug.cgi?id=309221
rdar://problem/171786018
Reviewed by Yijia Huang.
On some ICU versions, uloc_toLanguageTag() fails when the ICU locale ID contains
single-character keywords from non-Unicode BCP 47 extensions like -a- or -x-.
This causes new Intl.Locale("en-a-not-assigned").maximize() to throw
RangeError: invalid language tag.
Let's always maximize/minimize only the base name (without keywords/extensions),
then merge extensions back. When uloc_toLanguageTag fails on the merged result,
strip non-Unicode (single-char) keywords, convert preserving Unicode extensions
(-u-), and append stored non-Unicode BCP 47 extensions separately.
We also make removeUnicodeLocaleExtension more efficient by avoiding
Vector<String> allocation.
* Source/JavaScriptCore/runtime/IntlLocale.cpp:
(JSC::buildLocaleIDWithUnicodeKeywords):
(JSC::IntlLocale::initializeLocale):
(JSC::IntlLocale::maximal):
(JSC::IntlLocale::minimal):
(JSC::IntlLocale::toString):
* Source/JavaScriptCore/runtime/IntlLocale.h:
* Source/JavaScriptCore/runtime/IntlObject.cpp:
(JSC::removeUnicodeLocaleExtension):
(JSC::extractNonUnicodeBCP47Extensions):
* Source/JavaScriptCore/runtime/IntlObject.h:
Canonical link: https://commits.webkit.org/308753@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications