Skip to content

Commit

Permalink
RegExp.prototype[Symbols.match] builtin function should read flags pr…
Browse files Browse the repository at this point in the history
…operty instead of global

Signed-off-by: Seonghyun Kim <[email protected]>
  • Loading branch information
ksh8281 committed Jul 22, 2024
1 parent 10922a3 commit 098222a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
10 changes: 7 additions & 3 deletions src/builtins/BuiltinRegExp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,12 @@ static Value builtinRegExpReplace(ExecutionState& state, Value thisValue, size_t
if (!functionalReplace) {
replaceValue = replaceValue.toString(state);
}
bool global = rx.asObject()->get(state, ObjectPropertyName(state, state.context()->staticStrings().global)).value(state, rx).toBoolean();

String* flags = rx.asObject()->get(state, ObjectPropertyName(state.context()->staticStrings().flags)).value(state, rx).toString(state);

bool global = flags->contains("g");
if (global) {
fullUnicode = rx.asObject()->get(state, ObjectPropertyName(state, state.context()->staticStrings().unicode)).value(state, rx).toBoolean();
fullUnicode = flags->contains("u");
rx.asObject()->setThrowsException(state, ObjectPropertyName(state, state.context()->staticStrings().lastIndex), Value(0), rx);
}
ValueVectorWithInlineStorage results;
Expand Down Expand Up @@ -532,7 +535,8 @@ static Value builtinRegExpMatch(ExecutionState& state, Value thisValue, size_t a
ASSERT(str != nullptr);

//21.2.5.6.8
bool global = rx.asObject()->get(state, ObjectPropertyName(state, state.context()->staticStrings().global)).value(state, rx).toBoolean();
String* flags = rx.asObject()->get(state, ObjectPropertyName(state.context()->staticStrings().flags)).value(state, rx).toString(state);
bool global = flags->contains("g");

if (!global) {
return regExpExec(state, rx.asObject(), str);
Expand Down
9 changes: 0 additions & 9 deletions tools/test/test262/excludelist.orig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -579,16 +579,7 @@
<test id="built-ins/Object/prototype/toString/symbol-tag-set-builtin"><reason>TODO</reason></test>
<test id="built-ins/Object/prototype/toString/symbol-tag-string-builtin"><reason>TODO</reason></test>
<test id="built-ins/Object/seal/proxy-with-defineProperty-handler"><reason>TODO</reason></test>
<test id="built-ins/RegExp/prototype/Symbol.match/builtin-infer-unicode"><reason>TODO</reason></test>
<test id="built-ins/RegExp/prototype/Symbol.match/flags-tostring-error"><reason>TODO</reason></test>
<test id="built-ins/RegExp/prototype/Symbol.match/get-flags-err"><reason>TODO</reason></test>
<test id="built-ins/RegExp/prototype/Symbol.match/get-unicode-error"><reason>TODO</reason></test>
<test id="built-ins/RegExp/prototype/Symbol.replace/flags-tostring-error"><reason>TODO</reason></test>
<test id="built-ins/RegExp/prototype/Symbol.replace/get-flags-err"><reason>TODO</reason></test>
<test id="built-ins/RegExp/prototype/Symbol.replace/get-unicode-error"><reason>TODO</reason></test>
<test id="built-ins/RegExp/prototype/Symbol.search/u-lastindex-advance"><reason>TODO</reason></test>
<test id="built-ins/RegExp/prototype/Symbol.split/u-lastindex-adv-thru-match"><reason>TODO</reason></test>
<test id="built-ins/RegExp/prototype/exec/u-lastindex-adv"><reason>TODO</reason></test>
<test id="built-ins/RegExp/prototype/source/value-line-terminator"><reason>TODO</reason></test>
<test id="built-ins/RegExp/prototype/unicodeSets/cross-realm"><reason>TODO</reason></test>
<test id="built-ins/RegExp/prototype/unicodeSets/length"><reason>TODO</reason></test>
Expand Down

0 comments on commit 098222a

Please sign in to comment.