summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2022-09-18 11:01:27 +0000
committerMoonchild <moonchild@palemoon.org>2022-09-18 11:01:27 +0000
commitfc5b767f5dbed652966eea65f61036a97d9b893a (patch)
treeb422d4f9a2f65f23761bc8bff825ad309404ee1f
parent302d46a0f999f8ec99bc65a6dab1b0b18d733dd6 (diff)
downloaduxp-fc5b767f5dbed652966eea65f61036a97d9b893a.tar.gz
Issue #2008 - Implement missing s parameter parsing and align case with spec.
This does 2 things. First, it adds parsing of the 's' parameter parsing to DOM object construction of regexes Second, it corrects the DOM property to be `dotAll` instead of `dotall` For consistency's sake, all function names and calls were renamed with the finalized casing. This resolves #2008
-rw-r--r--js/src/builtin/RegExp.cpp14
-rw-r--r--js/src/builtin/RegExp.h2
-rw-r--r--js/src/builtin/RegExp.js2
-rw-r--r--js/src/vm/CommonPropertyNames.h2
-rw-r--r--js/src/vm/RegExpObject.cpp10
-rw-r--r--js/src/vm/RegExpObject.h4
6 files changed, 21 insertions, 13 deletions
diff --git a/js/src/builtin/RegExp.cpp b/js/src/builtin/RegExp.cpp
index d1aa520663..2456ef065d 100644
--- a/js/src/builtin/RegExp.cpp
+++ b/js/src/builtin/RegExp.cpp
@@ -665,7 +665,7 @@ js::regexp_multiline(JSContext* cx, unsigned argc, JS::Value* vp)
// ES 2018 dotAll
MOZ_ALWAYS_INLINE bool
-regexp_dotall_impl(JSContext* cx, const CallArgs& args)
+regexp_dotAll_impl(JSContext* cx, const CallArgs& args)
{
MOZ_ASSERT(IsRegExpInstanceOrPrototype(args.thisv()));
@@ -675,15 +675,15 @@ regexp_dotall_impl(JSContext* cx, const CallArgs& args)
}
Rooted<RegExpObject*> reObj(cx, &args.thisv().toObject().as<RegExpObject>());
- args.rval().setBoolean(reObj->dotall());
+ args.rval().setBoolean(reObj->dotAll());
return true;
}
bool
-js::regexp_dotall(JSContext* cx, unsigned argc, JS::Value* vp)
+js::regexp_dotAll(JSContext* cx, unsigned argc, JS::Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
- return CallNonGenericMethod<IsRegExpInstanceOrPrototype, regexp_dotall_impl>(cx, args);
+ return CallNonGenericMethod<IsRegExpInstanceOrPrototype, regexp_dotAll_impl>(cx, args);
}
// ES 2017 draft rev32 21.2.5.10.
@@ -781,7 +781,7 @@ const JSPropertySpec js::regexp_properties[] = {
JS_PSG("source", regexp_source, 0),
JS_PSG("sticky", regexp_sticky, 0),
JS_PSG("unicode", regexp_unicode, 0),
- JS_PSG("dotall", regexp_dotall, 0),
+ JS_PSG("dotAll", regexp_dotAll, 0),
JS_PS_END
};
@@ -1667,10 +1667,10 @@ js::RegExpPrototypeOptimizableRaw(JSContext* cx, JSObject* proto)
return false;
JSNative dotAllGetter;
- if (!GetOwnNativeGetterPure(cx, proto, NameToId(cx->names().dotall), &dotAllGetter))
+ if (!GetOwnNativeGetterPure(cx, proto, NameToId(cx->names().dotAll), &dotAllGetter))
return false;
- if (dotAllGetter != regexp_dotall)
+ if (dotAllGetter != regexp_dotAll)
return false;
// Check if @@match, @@search, and exec are own data properties,
diff --git a/js/src/builtin/RegExp.h b/js/src/builtin/RegExp.h
index c9f7bac579..275efd7ce3 100644
--- a/js/src/builtin/RegExp.h
+++ b/js/src/builtin/RegExp.h
@@ -153,7 +153,7 @@ regexp_sticky(JSContext* cx, unsigned argc, JS::Value* vp);
extern MOZ_MUST_USE bool
regexp_unicode(JSContext* cx, unsigned argc, JS::Value* vp);
extern MOZ_MUST_USE bool
-regexp_dotall(JSContext* cx, unsigned argc, JS::Value* vp);
+regexp_dotAll(JSContext* cx, unsigned argc, JS::Value* vp);
} /* namespace js */
diff --git a/js/src/builtin/RegExp.js b/js/src/builtin/RegExp.js
index 7218fc0e8a..879375b988 100644
--- a/js/src/builtin/RegExp.js
+++ b/js/src/builtin/RegExp.js
@@ -34,7 +34,7 @@ function RegExpFlagsGetter() {
result += "y";
// ES2018
- if (R.dotall)
+ if (R.dotAll)
result += "s";
// Step 19.
diff --git a/js/src/vm/CommonPropertyNames.h b/js/src/vm/CommonPropertyNames.h
index 8ecd3a2083..5080e6ab09 100644
--- a/js/src/vm/CommonPropertyNames.h
+++ b/js/src/vm/CommonPropertyNames.h
@@ -99,7 +99,7 @@
macro(displayURL, displayURL, "displayURL") \
macro(do, do_, "do") \
macro(done, done, "done") \
- macro(dotall, dotall, "dotall") \
+ macro(dotAll, dotAll, "dotAll") \
macro(dotGenerator, dotGenerator, ".generator") \
macro(dotThis, dotThis, ".this") \
macro(each, each, "each") \
diff --git a/js/src/vm/RegExpObject.cpp b/js/src/vm/RegExpObject.cpp
index da6005b6c0..33b97a1174 100644
--- a/js/src/vm/RegExpObject.cpp
+++ b/js/src/vm/RegExpObject.cpp
@@ -167,6 +167,10 @@ RegExpObject::isOriginalFlagGetter(JSNative native, RegExpFlag* mask)
*mask = UnicodeFlag;
return true;
}
+ if (native == regexp_dotAll) {
+ *mask = DotAllFlag;
+ return true;
+ }
return false;
}
@@ -1016,7 +1020,7 @@ RegExpShared::compile(JSContext* cx, HandleAtom pattern, HandleLinearString inpu
irregexp::RegExpCompileData data;
if (!irregexp::ParsePattern(dummyTokenStream, cx->tempLifoAlloc(), pattern,
multiline(), mode == MatchOnly, unicode(), ignoreCase(),
- global(), sticky(), dotall(), &data))
+ global(), sticky(), dotAll(), &data))
{
return false;
}
@@ -1468,6 +1472,10 @@ ParseRegExpFlags(const CharT* chars, size_t length, RegExpFlag* flagsOut, char16
if (!HandleRegExpFlag(MultilineFlag, flagsOut))
return false;
break;
+ case 's':
+ if (!HandleRegExpFlag(DotAllFlag, flagsOut))
+ return false;
+ break;
case 'y':
if (!HandleRegExpFlag(StickyFlag, flagsOut))
return false;
diff --git a/js/src/vm/RegExpObject.h b/js/src/vm/RegExpObject.h
index d1de0c08ba..ca7a39ec65 100644
--- a/js/src/vm/RegExpObject.h
+++ b/js/src/vm/RegExpObject.h
@@ -194,7 +194,7 @@ class RegExpShared
bool multiline() const { return flags & MultilineFlag; }
bool sticky() const { return flags & StickyFlag; }
bool unicode() const { return flags & UnicodeFlag; }
- bool dotall() const { return flags & DotAllFlag; }
+ bool dotAll() const { return flags & DotAllFlag; }
bool isCompiled(CompilationMode mode, bool latin1,
ForceByteCodeEnum force = DontForceByteCode) const {
@@ -482,7 +482,7 @@ class RegExpObject : public NativeObject
bool multiline() const { return getFlags() & MultilineFlag; }
bool sticky() const { return getFlags() & StickyFlag; }
bool unicode() const { return getFlags() & UnicodeFlag; }
- bool dotall() const { return getFlags() & DotAllFlag; }
+ bool dotAll() const { return getFlags() & DotAllFlag; }
static bool isOriginalFlagGetter(JSNative native, RegExpFlag* mask);