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

Unified Diff: src/regexp/regexp-parser.cc

Issue 1568623004: [regexp] correctly parse non-BMP unicode escapes in atoms. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase correctly 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 | « src/parsing/scanner-character-streams.cc ('k') | test/cctest/test-regexp.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/regexp/regexp-parser.cc
diff --git a/src/regexp/regexp-parser.cc b/src/regexp/regexp-parser.cc
index 728be5ba7b7b5bcc5e86a3699a70c82c90361648..ad74b3d723e7b253af17094264df310663464a3c 100644
--- a/src/regexp/regexp-parser.cc
+++ b/src/regexp/regexp-parser.cc
@@ -417,7 +417,12 @@ RegExpTree* RegExpParser::ParseDisjunction() {
Advance(2);
uc32 value;
if (ParseUnicodeEscape(&value)) {
- builder->AddCharacter(value);
+ if (value > unibrow::Utf16::kMaxNonSurrogateCharCode) {
+ builder->AddCharacter(unibrow::Utf16::LeadSurrogate(value));
+ builder->AddCharacter(unibrow::Utf16::TrailSurrogate(value));
+ } else {
+ builder->AddCharacter(static_cast<uc16>(value));
+ }
} else if (!unicode_) {
builder->AddCharacter('u');
} else {
@@ -986,6 +991,11 @@ bool RegExpParser::ParseRegExp(Isolate* isolate, Zone* zone,
} else {
DCHECK(tree != NULL);
DCHECK(result->error.is_null());
+ if (FLAG_trace_regexp_parser) {
+ OFStream os(stdout);
+ tree->Print(os, zone);
+ os << "\n";
+ }
result->tree = tree;
int capture_count = parser.captures_started();
result->simple = tree->IsAtom() && parser.simple() && capture_count == 0;
« no previous file with comments | « src/parsing/scanner-character-streams.cc ('k') | test/cctest/test-regexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698