Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Unified Diff: src/js/regexp.js

Issue 1663543003: [regexp] fix zero-length matches for RegExp.prototype.@@split. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: address comment Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/harmony/unicode-regexp-zero-length.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/regexp.js
diff --git a/src/js/regexp.js b/src/js/regexp.js
index 2ad7e336ea8c30a7cc3c22dd35fad345f0864d09..fccbca679ab7723dcea723a7e0c20007d1be479f 100644
--- a/src/js/regexp.js
+++ b/src/js/regexp.js
@@ -296,6 +296,15 @@ function RegExpToString() {
}
+function AtSurrogatePair(subject, index) {
+ if (index + 1 >= subject.length) return false;
+ var first = %_StringCharCodeAt(subject, index);
+ if (first < 0xD800 || first > 0xDBFF) return false;
+ var second = %_StringCharCodeAt(subject, index + 1);
+ return second >= 0xDC00 || second <= 0xDFFF;
+}
+
+
// ES6 21.2.5.11.
function RegExpSplit(string, limit) {
// TODO(yangguo): allow non-regexp receivers.
@@ -337,7 +346,11 @@ function RegExpSplit(string, limit) {
// We ignore a zero-length match at the currentIndex.
if (startIndex === endIndex && endIndex === currentIndex) {
- startIndex++;
+ if (REGEXP_UNICODE(this) && AtSurrogatePair(subject, startIndex)) {
+ startIndex += 2;
+ } else {
+ startIndex++;
+ }
continue;
}
« no previous file with comments | « no previous file | test/mjsunit/harmony/unicode-regexp-zero-length.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698