{"record":{"id":"3a3a0bd07cc889e4","repo":"OrchardCMS/OrchardCore","slug":"regexp-exec-called-on-incompatible-receiver","errorCode":null,"errorMessage":"RegExp#exec called on incompatible receiver","messagePattern":"RegExp#exec called on incompatible receiver","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/OrchardCore.Modules/OrchardCore.Resources/wwwroot/Vendor/vue-draggable-2.24.3/vuedraggable.common.js","lineNumber":874,"sourceCode":"\"use strict\";\n\n\nvar classof = __webpack_require__(\"23c6\");\nvar builtinExec = RegExp.prototype.exec;\n\n // `RegExpExec` abstract operation\n// https://tc39.github.io/ecma262/#sec-regexpexec\nmodule.exports = function (R, S) {\n  var exec = R.exec;\n  if (typeof exec === 'function') {\n    var result = exec.call(R, S);\n    if (typeof result !== 'object') {\n      throw new TypeError('RegExp exec method returned something other than an Object or null');\n    }\n    return result;\n  }\n  if (classof(R) !== 'RegExp') {\n    throw new TypeError('RegExp#exec called on incompatible receiver');\n  }\n  return builtinExec.call(R, S);\n};\n\n\n/***/ }),\n\n/***/ \"613b\":\n/***/ (function(module, exports, __webpack_require__) {\n\nvar shared = __webpack_require__(\"5537\")('keys');\nvar uid = __webpack_require__(\"ca5a\");\nmodule.exports = function (key) {\n  return shared[key] || (shared[key] = uid(key));\n};\n\n\n/***/ }),","sourceCodeStart":856,"sourceCodeEnd":892,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore.Modules/OrchardCore.Resources/wwwroot/Vendor/vue-draggable-2.24.3/vuedraggable.common.js#L856-L892","documentation":"core-js's RegExp#exec shim (bundled into vuedraggable.common.js) throws this TypeError when the receiver R has no function-valued exec and its internal classof is not 'RegExp' — i.e. RegExp.prototype.exec was called on an object that is not a RegExp (and not a well-behaved RegExp-like with a proper exec).","triggerScenarios":"Calling String.prototype.match/replace/split (or .test/.exec) with a this-value or pattern argument that is an object merely resembling a RegExp (e.g. Object.create(RegExp.prototype), a cloned/plain object, a value from another iframe/realm or vm context) so the shim classifies it as non-RegExp.","commonSituations":"Cross-realm RegExp (object created in another iframe/Node vm) failing classof checks; library config code doing regex.test(str) with test passed unbound or called with a non-regex this; destructuring pattern values from JSON/config that are plain objects; polyfill collisions where the shimmed exec runs on foreign objects.","solutions":["Ensure the value passed as a pattern is a real RegExp in the same realm: use `new RegExp(pattern)` on the consuming side before calling match/test/exec.","Bind/apply correctly: call regex.exec(str) / regex.test(str) on the RegExp instance, not via unbound function references.","If supporting cross-realm regexes, normalize them: `const re = obj instanceof RegExp ? new RegExp(obj.source, obj.flags) : obj;`","Audit for polyfills that wrap String.prototype.match/replace with a shimmed RegExpExec and remove duplicate polyfill loads.","Validate config-supplied 'pattern' values with typeof v === 'string' ? new RegExp(v) : v before use."],"exampleFix":"// before\nconst test = RegExp.prototype.test;\ntest.call(somePlainObject, 'input'); // not a RegExp -> TypeError\n// after\nconst re = somePlainObject instanceof RegExp ? somePlainObject : new RegExp(String(somePlainObject));\nre.test('input');","handlingStrategy":"validation","validationCode":"function assertRegExp(v) { if (!(v instanceof RegExp)) throw new TypeError('Pattern must be a RegExp in the current realm, got: ' + Object.prototype.toString.call(v)); }","typeGuard":"function isRegExp(v) { return Object.prototype.toString.call(v) === '[object RegExp]'; }","tryCatchPattern":"try { return pattern.exec(input); } catch (e) { if (e instanceof TypeError && /incompatible receiver/.test(e.message)) { const re = new RegExp(pattern.source ?? String(pattern), pattern.flags ?? ''); return re.exec(input); } throw e; }","preventionTips":["Call test/exec/match as methods on a real RegExp instance, never via unbound references","Normalize cross-realm (iframe/vm) regexes with new RegExp(re.source, re.flags)","Validate config-supplied patterns: strings become new RegExp(v); reject plain objects","Deduplicate polyfill bundles so core-js shims don't run against foreign receivers","Prefer String.prototype methods with literal patterns over generic exec helpers"],"tags":["regexp","core-js","receiver","typeerror"],"backgroundTag":"type-mismatch","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}