v8/test/mjsunit/regress/regress-v8-13410.js
pthier dd92fe999b [regexp] Fix wrong match of lone surrogates
A surrogate pair split by an "always succeeding" backreference
(backreference capturing undefined, because it hasn't captured anything
yet) was incorrectly combined into a surrogate pair, resulting in
incorrect matches.

Bug: v8:13410
Change-Id: I2faf9ca5f9fcfd55cd6933a1ea038c88f8d3f524
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4013159
Commit-Queue: Patrick Thier <pthier@chromium.org>
Reviewed-by: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#84276}
2022-11-15 15:43:15 +00:00

16 lines
771 B
JavaScript

// Copyright 2022 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.
// Make sure lone surrogates don't match combined surrogates.
assertFalse(/[\ud800-\udfff]+/u.test('\ud801\udc0f'));
// Surrogate pairs split by an "always succeeding" backref shouldn't match
// combined surrogates.
assertFalse(/(\ud801\1\udc0f)/u.test('\ud801\udc0f'));
assertFalse(/(\ud801\1?\udc0f)/u.test('\ud801\udc0f'));
assertFalse(/(\ud801\1{0}\udc0f)/u.test('\ud801\udc0f'));
assertFalse(new RegExp('(\ud801\\1\udc0f)','u').test('\ud801\udc0f'));
assertFalse(new RegExp('(\ud801\\1?\udc0f)','u').test('\ud801\udc0f'));
assertFalse(new RegExp('(\ud801\\1{0}\udc0f)','u').test('\ud801\udc0f'));