commit d314389fc89c949297261180264c1c7ec56aaf08 parent 742af503898610c33f23a32fb8047833807ca2d3 Author: Iain Ireland <iireland@mozilla.com> Date: Thu, 8 Jan 2026 20:04:00 +0000 Bug 2007291: Ignore legacy flag when pref is disabled r=dminor Differential Revision: https://phabricator.services.mozilla.com/D278337 Diffstat:
| M | js/src/builtin/RegExp.cpp | | | 7 | ++++++- |
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/js/src/builtin/RegExp.cpp b/js/src/builtin/RegExp.cpp @@ -872,7 +872,12 @@ bool js::regexp_construct_raw_flags(JSContext* cx, unsigned argc, Value* vp) { uint32_t rawFlags = args[1].toInt32(); JS::RegExpFlags flags = AssertedCast<uint8_t>(rawFlags & RegExpFlag::AllFlags); - bool legacy = args[2].toBoolean(); + + // Self-hosted code can't check prefs efficiently. In some cases it will + // call this with the flag set even when the pref is disabled, in which + // case we should ignore it. + // TODO(bug 2009034): Clean this up when we ship the proposal. + bool legacy = args[2].toBoolean() && JS::Prefs::experimental_legacy_regexp(); // Step 7. RegExpObject* regexp = RegExpAlloc(cx, GenericObject);