From 14086c69e79720328115d55720e75c0382fd328f Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Sun, 5 Sep 2021 18:31:22 -0400 Subject: [PATCH] LibJS: Only remove Unicode locale extensions during the LookupMatcher AO This was one of the first AOs used for Intl, and I misinterpreted the spec. Rather than removing all extensions, we must only remove Unicode locale extensions. Also use LocaleID::to_string() here instead of the heavier canonical string method, because the locale is already canonical. --- .../Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp index 39f8b51229..1f2d7a0774 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp @@ -274,11 +274,9 @@ static MatcherResult lookup_matcher(Vector const& requested_locales) auto locale_id = Unicode::parse_unicode_locale_id(locale); VERIFY(locale_id.has_value()); - auto extensions = move(locale_id->extensions); - locale_id->private_use_extensions.clear(); - // a. Let noExtensionsLocale be the String value that is locale with any Unicode locale extension sequences removed. - auto no_extensions_locale = JS::Intl::canonicalize_unicode_locale_id(*locale_id); + auto extensions = locale_id->remove_extension_type(); + auto no_extensions_locale = locale_id->to_string(); // b. Let availableLocale be BestAvailableLocale(availableLocales, noExtensionsLocale). auto available_locale = best_available_locale(no_extensions_locale); @@ -292,7 +290,7 @@ static MatcherResult lookup_matcher(Vector const& requested_locales) if (locale != no_extensions_locale) { // 1. Let extension be the String value consisting of the substring of the Unicode locale extension sequence within locale. // 2. Set result.[[extension]] to extension. - result.extensions = move(extensions); + result.extensions.extend(move(extensions)); } // iii. Return result.