Commit 33c813c6 authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

Revert "[Intl] Fix legacy error handling"

This reverts commit 1f5ab936.

Reason for revert: FYI bot failures https://ci.chromium.org/p/v8/builders/luci.v8.ci/Linux%20Tests%20(dbg)(1)/6327

Original change's description:
> [Intl] Fix legacy error handling
> 
> Bug: v8:5751
> Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng
> Change-Id: I382404f4c59c1e997ea0fb58f3a995b653c0d6bc
> Reviewed-on: https://chromium-review.googlesource.com/1148031
> Reviewed-by: Jakob Gruber <jgruber@chromium.org>
> Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#54625}

TBR=gsathya@chromium.org,jgruber@chromium.org

Change-Id: I57f6d69d38afe1734b6963fd81420c73b0d23922
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:5751
Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng
Reviewed-on: https://chromium-review.googlesource.com/1148360Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54641}
parent 7af0ebed
......@@ -803,7 +803,14 @@ function canonicalizeLanguageTag(localeID) {
}
// ECMA 402 6.2.3
return %CanonicalizeLanguageTag(localeString);
var tag = %CanonicalizeLanguageTag(localeString);
// TODO(jshin): This should not happen because the structural validity
// is already checked. If that's the case, remove this.
if (tag === 'invalid-tag') {
throw %make_range_error(kInvalidLanguageTag, localeString);
}
return tag;
}
......
......@@ -55,14 +55,13 @@ namespace internal {
// ECMA 402 6.2.3
RUNTIME_FUNCTION(Runtime_CanonicalizeLanguageTag) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(String, locale_id_str, 0);
v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
Factory* factory = isolate->factory();
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(String, locale_id_str, 0);
v8::String::Utf8Value locale_id(v8_isolate,
v8::Utils::ToLocal(locale_id_str));
......@@ -73,14 +72,15 @@ RUNTIME_FUNCTION(Runtime_CanonicalizeLanguageTag) {
// handle long locale names better. See
// https://ssl.icu-project.org/trac/ticket/13417 .
// Return value which denotes invalid language tag.
const char* const kInvalidTag = "invalid-tag";
UErrorCode error = U_ZERO_ERROR;
char icu_result[ULOC_FULLNAME_CAPACITY];
uloc_forLanguageTag(*locale_id, icu_result, ULOC_FULLNAME_CAPACITY, nullptr,
&error);
if (U_FAILURE(error) || error == U_STRING_NOT_TERMINATED_WARNING) {
THROW_NEW_ERROR_RETURN_FAILURE(
isolate,
NewRangeError(MessageTemplate::kInvalidLanguageTag, locale_id_str));
return *factory->NewStringFromAsciiChecked(kInvalidTag);
}
char result[ULOC_FULLNAME_CAPACITY];
......@@ -89,12 +89,9 @@ RUNTIME_FUNCTION(Runtime_CanonicalizeLanguageTag) {
uloc_toLanguageTag(icu_result, result, ULOC_FULLNAME_CAPACITY, TRUE, &error);
if (U_FAILURE(error) || error == U_STRING_NOT_TERMINATED_WARNING) {
THROW_NEW_ERROR_RETURN_FAILURE(
isolate,
NewRangeError(MessageTemplate::kInvalidLanguageTag, locale_id_str));
return *factory->NewStringFromAsciiChecked(kInvalidTag);
}
DCHECK_NOT_NULL(result);
return *factory->NewStringFromAsciiChecked(result);
}
......
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