Fix bugs in DisplayNames v2
Bug: v8:12043 Change-Id: I0691387546ec82616bdf22d19c8a990c8164fca2 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3071915 Reviewed-by: Jakob Kummerow <jkummerow@chromium.org> Commit-Queue: Frank Tang <ftang@chromium.org> Cr-Commit-Position: refs/heads/master@{#76147}
This commit is contained in:
parent
a910264a76
commit
3ff1904941
@ -238,6 +238,12 @@ class CalendarNames : public KeyValueDisplayNames {
|
||||
~CalendarNames() override = default;
|
||||
Maybe<icu::UnicodeString> of(Isolate* isolate,
|
||||
const char* code) const override {
|
||||
std::string code_str(code);
|
||||
if (!Intl::IsWellFormedCalendar(code_str)) {
|
||||
THROW_NEW_ERROR_RETURN_VALUE(
|
||||
isolate, NewRangeError(MessageTemplate::kInvalidArgument),
|
||||
Nothing<icu::UnicodeString>());
|
||||
}
|
||||
return KeyValueDisplayNames::of(isolate, strcmp(code, "gregory") == 0
|
||||
? "gregorian"
|
||||
: strcmp(code, "ethioaa") == 0
|
||||
@ -300,9 +306,7 @@ class DateTimeFieldNames : public DisplayNamesInternal {
|
||||
public:
|
||||
DateTimeFieldNames(const icu::Locale& locale, JSDisplayNames::Style style,
|
||||
bool fallback)
|
||||
: locale_(locale),
|
||||
width_(StyleToUDateTimePGDisplayWidth(style)),
|
||||
fallback_(fallback) {
|
||||
: locale_(locale), width_(StyleToUDateTimePGDisplayWidth(style)) {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
generator_.reset(
|
||||
icu::DateTimePatternGenerator::createInstance(locale_, status));
|
||||
@ -315,9 +319,6 @@ class DateTimeFieldNames : public DisplayNamesInternal {
|
||||
const char* code) const override {
|
||||
UDateTimePatternField field = StringToUDateTimePatternField(code);
|
||||
if (field == UDATPG_FIELD_COUNT) {
|
||||
if (fallback_) {
|
||||
return Just(icu::UnicodeString(code, -1, US_INV));
|
||||
}
|
||||
THROW_NEW_ERROR_RETURN_VALUE(
|
||||
isolate, NewRangeError(MessageTemplate::kInvalidArgument),
|
||||
Nothing<icu::UnicodeString>());
|
||||
@ -329,7 +330,6 @@ class DateTimeFieldNames : public DisplayNamesInternal {
|
||||
icu::Locale locale_;
|
||||
UDateTimePGDisplayWidth width_;
|
||||
std::unique_ptr<icu::DateTimePatternGenerator> generator_;
|
||||
bool fallback_;
|
||||
};
|
||||
|
||||
DisplayNamesInternal* CreateInternal(const icu::Locale& locale,
|
||||
|
@ -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) {
|
||||
|
@ -598,10 +598,6 @@
|
||||
# https://bugs.chromium.org/p/v8/issues/detail?id=11544
|
||||
'built-ins/Temporal/*': [FAIL],
|
||||
|
||||
# https://bugs.chromium.org/p/v8/issues/detail?id=12043
|
||||
'intl402/DisplayNames/prototype/of/type-datetimefield-invalid': [FAIL],
|
||||
'intl402/DisplayNames/prototype/of/type-calendar-invalid': [FAIL],
|
||||
|
||||
# https://bugs.chromium.org/p/v8/issues/detail?id=12044
|
||||
'built-ins/Array/prototype/Symbol.unscopables/value': [FAIL],
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user