Commit 6b3cd580 authored by jgruber's avatar jgruber Committed by Commit bot

[regexp] Fix incorrect range checks in AtSurrogatePair

R=littledan@chromium.org
BUG=v8:5339

Review-Url: https://codereview.chromium.org/2337763003
Cr-Commit-Position: refs/heads/master@{#39403}
parent 8df547d4
...@@ -293,7 +293,7 @@ function AtSurrogatePair(subject, index) { ...@@ -293,7 +293,7 @@ function AtSurrogatePair(subject, index) {
var first = %_StringCharCodeAt(subject, index); var first = %_StringCharCodeAt(subject, index);
if (first < 0xD800 || first > 0xDBFF) return false; if (first < 0xD800 || first > 0xDBFF) return false;
var second = %_StringCharCodeAt(subject, index + 1); var second = %_StringCharCodeAt(subject, index + 1);
return second >= 0xDC00 || second <= 0xDFFF; return second >= 0xDC00 && second <= 0xDFFF;
} }
......
...@@ -726,3 +726,8 @@ assertEquals(["a", "", ""], /(\2).(\1)/.exec("aba")); ...@@ -726,3 +726,8 @@ assertEquals(["a", "", ""], /(\2).(\1)/.exec("aba"));
assertEquals(["aba", "a", "a"], /(.\2).(\1)/.exec("aba")); assertEquals(["aba", "a", "a"], /(.\2).(\1)/.exec("aba"));
assertEquals(["acbc", "c", "c"], /a(.\2)b(\1)$/.exec("acbc")); assertEquals(["acbc", "c", "c"], /a(.\2)b(\1)$/.exec("acbc"));
assertEquals(["acbc", "c", "c"], /a(.\2)b(\1)/.exec("aabcacbc")); assertEquals(["acbc", "c", "c"], /a(.\2)b(\1)/.exec("aabcacbc"));
// Test surrogate pair detection in split.
// \u{daff}\u{e000} is not a surrogate pair, while \u{daff}\u{dfff} is.
assertEquals(["\u{daff}", "\u{e000}"], "\u{daff}\u{e000}".split(/[a-z]{0,1}/u));
assertEquals(["\u{daff}\u{dfff}"], "\u{daff}\u{dfff}".split(/[a-z]{0,1}/u));
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