[Intl] Fix getting undefined property crash
If the key of the u-ext has no value it will return error so we should just return undefined for that case. Bug: v8:8663 Change-Id: I7446ad74c8d0609ad268385b6f4d986060424ce9 Reviewed-on: https://chromium-review.googlesource.com/c/1404194 Commit-Queue: Frank Tang <ftang@chromium.org> Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org> Cr-Commit-Position: refs/heads/master@{#58682}
This commit is contained in:
parent
76c377a344
commit
d286fe3dbc
@ -148,8 +148,7 @@ Handle<Object> UnicodeKeywordValue(Isolate* isolate, Handle<JSLocale> locale,
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
std::string value =
|
||||
icu_locale->getUnicodeKeywordValue<std::string>(key, status);
|
||||
CHECK(U_SUCCESS(status));
|
||||
if (value == "") {
|
||||
if (status == U_ILLEGAL_ARGUMENT_ERROR || value == "") {
|
||||
return isolate->factory()->undefined_value();
|
||||
}
|
||||
return isolate->factory()->NewStringFromAsciiChecked(value.c_str());
|
||||
|
22
test/intl/locale/property.js
Normal file
22
test/intl/locale/property.js
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright 2019 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flags: --harmony-locale
|
||||
|
||||
// Make sure that accessing locale property will return undefined instead of
|
||||
// crash.
|
||||
|
||||
let locale = new Intl.Locale('sr');
|
||||
|
||||
assertEquals('sr', locale.toString());
|
||||
assertEquals('sr', locale.baseName);
|
||||
assertEquals('sr', locale.language);
|
||||
assertEquals(undefined, locale.script);
|
||||
assertEquals(undefined, locale.region);
|
||||
assertEquals(false, locale.numeric);
|
||||
assertEquals(undefined, locale.calendar);
|
||||
assertEquals(undefined, locale.collation);
|
||||
assertEquals(undefined, locale.hourCycle);
|
||||
assertEquals(undefined, locale.caseFirst);
|
||||
assertEquals(undefined, locale.numberingSystem);
|
Loading…
Reference in New Issue
Block a user