diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/v8/src/regexp/regexp-parser.cc | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/v8/src/regexp/regexp-parser.cc')
-rw-r--r-- | chromium/v8/src/regexp/regexp-parser.cc | 58 |
1 files changed, 39 insertions, 19 deletions
diff --git a/chromium/v8/src/regexp/regexp-parser.cc b/chromium/v8/src/regexp/regexp-parser.cc index 3c1115414fb..7b87044ca65 100644 --- a/chromium/v8/src/regexp/regexp-parser.cc +++ b/chromium/v8/src/regexp/regexp-parser.cc @@ -1301,7 +1301,7 @@ bool LookupSpecialPropertyValueName(const char* name, return true; } -// Explicitly whitelist supported binary properties. The spec forbids supporting +// Explicitly allowlist supported binary properties. The spec forbids supporting // properties outside of this set to ensure interoperability. bool IsSupportedBinaryProperty(UProperty property) { switch (property) { @@ -1550,7 +1550,7 @@ bool RegExpParser::ParseUnlimitedLengthHexNumber(int max_value, uc32* value) { } while (d >= 0) { x = x * 16 + d; - if (x > max_value) { + if (x > static_cast<uc32>(max_value)) { return false; } Advance(); @@ -1789,34 +1789,54 @@ RegExpTree* RegExpParser::ParseCharacterClass(const RegExpBuilder* builder) { #undef CHECK_FAILED - -bool RegExpParser::ParseRegExp(Isolate* isolate, Zone* zone, - FlatStringReader* input, JSRegExp::Flags flags, - RegExpCompileData* result) { +bool RegExpParser::Parse(RegExpCompileData* result, + const DisallowHeapAllocation&) { DCHECK(result != nullptr); - RegExpParser parser(input, flags, isolate, zone); - RegExpTree* tree = parser.ParsePattern(); - if (parser.failed()) { + RegExpTree* tree = ParsePattern(); + if (failed()) { DCHECK(tree == nullptr); - DCHECK(parser.error_ != RegExpError::kNone); - result->error = parser.error_; - result->error_pos = parser.error_pos_; + DCHECK(error_ != RegExpError::kNone); + result->error = error_; + result->error_pos = error_pos_; } else { DCHECK(tree != nullptr); - DCHECK(parser.error_ == RegExpError::kNone); + DCHECK(error_ == RegExpError::kNone); if (FLAG_trace_regexp_parser) { StdoutStream os; - tree->Print(os, zone); + tree->Print(os, zone()); os << "\n"; } result->tree = tree; - int capture_count = parser.captures_started(); - result->simple = tree->IsAtom() && parser.simple() && capture_count == 0; - result->contains_anchor = parser.contains_anchor(); - result->capture_name_map = parser.CreateCaptureNameMap(); + int capture_count = captures_started(); + result->simple = tree->IsAtom() && simple() && capture_count == 0; + result->contains_anchor = contains_anchor(); result->capture_count = capture_count; } - return !parser.failed(); + return !failed(); +} + +bool RegExpParser::ParseRegExp(Isolate* isolate, Zone* zone, + FlatStringReader* input, JSRegExp::Flags flags, + RegExpCompileData* result) { + RegExpParser parser(input, flags, isolate, zone); + bool success; + { + DisallowHeapAllocation no_gc; + success = parser.Parse(result, no_gc); + } + if (success) { + result->capture_name_map = parser.CreateCaptureNameMap(); + } + return success; +} + +bool RegExpParser::VerifyRegExpSyntax(Isolate* isolate, Zone* zone, + FlatStringReader* input, + JSRegExp::Flags flags, + RegExpCompileData* result, + const DisallowHeapAllocation& no_gc) { + RegExpParser parser(input, flags, isolate, zone); + return parser.Parse(result, no_gc); } RegExpBuilder::RegExpBuilder(Zone* zone, JSRegExp::Flags flags) |