[Intl] Fix /k/i.test('\u212A')

Add logic stated in

Bug: v8:9731
Change-Id: I0b3468bbad11a178f36d682febd0e44214646de8
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1828279
Commit-Queue: Frank Tang <ftang@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64027}
This commit is contained in:
Frank Tang 2019-09-27 10:00:08 -07:00 committed by Commit Bot
parent 5134ca885f
commit 7dedd92998
2 changed files with 23 additions and 1 deletions

View File

@ -736,7 +736,14 @@ static int GetCaseIndependentLetters(Isolate* isolate, uc16 character,
CHECK(end - start + items <= letter_length);
while (start <= end) {
if (one_byte_subject && start > String::kMaxOneByteCharCode) break;
letters[items++] = (unibrow::uchar)(start);
// Only add to the output if character is not in ASCII range
// or the case equivalent character is in ASCII range.
// #sec-runtime-semantics-canonicalize-ch
// 3.g If the numeric value of ch ≥ 128 and the numeric value of cu < 128,
// return ch.
if (!((start >= 128) && (character < 128))) {
letters[items++] = (unibrow::uchar)(start);
}
start++;
}
}

15
test/intl/regress-9731.js Normal file
View File

@ -0,0 +1,15 @@
// 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.
assertFalse(/k/i.test('\u212A'));
assertTrue(/k/i.test('K'));
assertTrue(/k/i.test('k'));
assertFalse(/K/i.test('\u212A'));
assertTrue(/K/i.test('K'));
assertTrue(/K/i.test('k'));
assertTrue(/\u212A/i.test('\u212A'));
assertFalse(/\u212A/i.test('k'));
assertFalse(/\u212A/i.test('K'));