Commit fbfbc5c2 authored by Frank Tang's avatar Frank Tang Committed by Commit Bot

[intl] Validate locale by LocaleBuilder

LocaleBuilder validates better, it also fixes most cases in
transformed-ext-invalid except one.

Bug: v8:10447
Change-Id: I6fed6692ca3264198e42ccc3d9ca4bfb54fb0517
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2549688
Commit-Queue: Frank Tang <ftang@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71300}
parent e53c7972
......@@ -810,21 +810,8 @@ Maybe<std::string> CanonicalizeLanguageTag(Isolate* isolate,
Nothing<std::string>());
}
// reject attribute of wrong length.
if (std::strstr(icu_locale.getName(), "attribute=") != nullptr) {
std::string attribute =
icu_locale.getKeywordValue<std::string>("attribute", error);
if (U_SUCCESS(error) &&
(attribute.length() < 3 || attribute.length() > 8)) {
THROW_NEW_ERROR_RETURN_VALUE(
isolate,
NewRangeError(
MessageTemplate::kInvalidLanguageTag,
isolate->factory()->NewStringFromAsciiChecked(locale.c_str())),
Nothing<std::string>());
}
}
// Use LocaleBuilder to validate locale.
icu_locale = icu::LocaleBuilder().setLocale(icu_locale).build(error);
icu_locale.canonicalize(error);
if (U_FAILURE(error) || icu_locale.isBogus()) {
THROW_NEW_ERROR_RETURN_VALUE(
......
......@@ -13,7 +13,6 @@ for (let locale of invalid_locales) {
}
var not_so_long_locales = [
"bs-u-nu-bzcu-cab-cabs-avnlubs-avnihu-zcu-cab-cbs-avnllubs-avnihq-zcu-cab-cbs-ubs-avnihu-cabs-flus-xxd-vnluy",
"bs-u-nu-bzcu-cab-cabs-avnlubs-avnihu-zcu-cab-cbs-avnllubs-avnihq-zcu-cab-cbs-ubs-avnihu-cabs-flus-xxd",
"bs-u-nu-bzcu-cab-cabs-avnlubs-avnihu-zcu",
];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment