Commit 19996d6d authored by Frank Tang's avatar Frank Tang Committed by V8 LUCI CQ

[intl] Change JSLocale::Is38AlphaNumList

Move from recusion to loop to avoid stack overflow

Bug: v8:12059
Change-Id: I44981f4271495adf00d7697114663f966b8f9f11
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3087937Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#76252}
parent 363a591d
......@@ -177,19 +177,24 @@ int32_t weekdayFromEDaysOfWeek(icu::Calendar::EDaysOfWeek eDaysOfWeek) {
} // namespace
bool JSLocale::Is38AlphaNumList(const std::string& value) {
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);
}
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::Is38AlphaNumList(const std::string& in) {
std::string value = in;
while (true) {
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);
}
if (found_underscore == std::string::npos ||
found_dash < found_underscore) {
if (!IsAlphanum(value.substr(0, found_dash), 3, 8)) return false;
value = value.substr(found_dash + 1);
} else {
if (!IsAlphanum(value.substr(0, found_underscore), 3, 8)) return false;
value = value.substr(found_underscore + 1);
}
}
}
bool JSLocale::Is3Alpha(const std::string& value) {
......
......@@ -31,6 +31,11 @@
'overrides/caching': [PASS, FAIL],
}], # ALWAYS
['asan == True or msan == True or tsan == True', {
# Take too long to run
'regress-12059': [SKIP],
}],
['gc_stress', {
# Push limit of stack, too flaky with machine with more memory.
'regress-1130489': [SKIP],
......
// Copyright 2021 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.
assertThrows(
() => new Intl.DateTimeFormat('en', {calendar: 'abc-'.repeat(100000)}),
RangeError,
"Invalid calendar : " + ('abc-'.repeat(100000)));
assertThrows(
() => new Intl.DateTimeFormat('en', {calendar: 'abc_'.repeat(100000)}),
RangeError,
"Invalid calendar : " + ('abc_'.repeat(100000)));
assertThrows(
() => new Intl.DateTimeFormat('en', {calendar: 'abc_efgh-'.repeat(100000)}),
RangeError,
"Invalid calendar : " + ('abc_efgh-'.repeat(100000)));
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