diff options
Diffstat (limited to 'deps/v8/src/objects/js-locale.cc')
-rw-r--r-- | deps/v8/src/objects/js-locale.cc | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/deps/v8/src/objects/js-locale.cc b/deps/v8/src/objects/js-locale.cc index 98ce154336..64644abad2 100644 --- a/deps/v8/src/objects/js-locale.cc +++ b/deps/v8/src/objects/js-locale.cc @@ -178,12 +178,18 @@ int32_t weekdayFromEDaysOfWeek(icu::Calendar::EDaysOfWeek eDaysOfWeek) { } // namespace bool JSLocale::Is38AlphaNumList(const std::string& value) { - std::size_t found = value.find("-"); - if (found == std::string::npos) { + std::size_t found_dash = value.find("-"); + std::size_t found_underscore = value.find("_"); + if (found_dash == std::string::npos && + found_underscore == std::string::npos) { return IsAlphanum(value, 3, 8); } - return IsAlphanum(value.substr(0, found), 3, 8) && - JSLocale::Is38AlphaNumList(value.substr(found + 1)); + if (found_underscore == std::string::npos || found_dash < found_underscore) { + return IsAlphanum(value.substr(0, found_dash), 3, 8) && + JSLocale::Is38AlphaNumList(value.substr(found_dash + 1)); + } + return IsAlphanum(value.substr(0, found_underscore), 3, 8) && + JSLocale::Is38AlphaNumList(value.substr(found_underscore + 1)); } bool JSLocale::Is3Alpha(const std::string& value) { @@ -425,8 +431,13 @@ MaybeHandle<JSLocale> JSLocale::Maximize(Isolate* isolate, // Base name is not changed result = source; } - DCHECK(U_SUCCESS(status)); - DCHECK(!result.isBogus()); + if (U_FAILURE(status) || result.isBogus()) { + // Due to https://unicode-org.atlassian.net/browse/ICU-21639 + // Valid but super long locale will fail. Just throw here for now. + THROW_NEW_ERROR(isolate, + NewRangeError(MessageTemplate::kLocaleBadParameters), + JSLocale); + } return Construct(isolate, result); } @@ -455,8 +466,13 @@ MaybeHandle<JSLocale> JSLocale::Minimize(Isolate* isolate, // Base name is not changed result = source; } - DCHECK(U_SUCCESS(status)); - DCHECK(!result.isBogus()); + if (U_FAILURE(status) || result.isBogus()) { + // Due to https://unicode-org.atlassian.net/browse/ICU-21639 + // Valid but super long locale will fail. Just throw here for now. + THROW_NEW_ERROR(isolate, + NewRangeError(MessageTemplate::kLocaleBadParameters), + JSLocale); + } return Construct(isolate, result); } |