Skip to content

Commit

Permalink
RegExp.prototype.compile should not accept sub-class of RegExp
Browse files Browse the repository at this point in the history
Signed-off-by: Seonghyun Kim <[email protected]>
  • Loading branch information
ksh8281 authored and clover2123 committed Jul 16, 2024
1 parent b3deb87 commit bddd8a8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/builtins/BuiltinRegExp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ static Value builtinRegExpCompile(ExecutionState& state, Value thisValue, size_t
Optional<Object*> proto = thisValue.asObject()->getPrototypeObject(state);
Context* calleeContext = state.resolveCallee()->codeBlock()->context();

if (!proto || !proto->isRegExpPrototypeObject()) {
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, ErrorObject::Messages::GlobalObject_ThisNotRegExpObject);
}

bool match = false;
while (proto) {
Value c = proto->getOwnProperty(state, ObjectPropertyName(state.context()->staticStrings().constructor)).value(state, proto.value());
Expand Down
1 change: 0 additions & 1 deletion tools/test/test262/excludelist.orig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
<test id="intl402/NumberFormat/prototype/formatToParts/signDisplay-ko-KR"><reason>ICU 67 returns wrong result with -0.0001</reason></test>
<test id="intl402/NumberFormat/prototype/formatToParts/signDisplay-zh-TW"><reason>ICU 67 returns wrong result with -0.0001</reason></test>

<test id="annexB/built-ins/RegExp/prototype/compile/this-subclass-instance"><reason>TODO</reason></test>
<test id="annexB/language/comments/multi-line-html-close"><reason>TODO</reason></test>
<test id="annexB/language/eval-code/direct/script-decl-lex-collision-in-sloppy-mode"><reason>TODO</reason></test>
<test id="annexB/language/function-code/block-decl-func-skip-arguments"><reason>TODO</reason></test>
Expand Down

0 comments on commit bddd8a8

Please sign in to comment.