Skip to content

Commit 5f756b4

Browse files
Fix ReDoS (#1980)
* Simplify the regex to make it easier to fix the ReDoS. The new version isn't exactly equivalent to the old: it matches a superset of the strings matched by the old version. * Fix ReDoS
1 parent 39cdc9b commit 5f756b4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/autoInject.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import auto from './auto.js'
22
import wrapAsync from './internal/wrapAsync.js'
33
import { isAsync } from './internal/wrapAsync.js'
44

5-
var FN_ARGS = /^(?:async\s+)?(?:function)?\s*\w*\s*\(\s*([^)]+)\s*\)(?:\s*{)/;
6-
var ARROW_FN_ARGS = /^(?:async\s+)?\(?\s*([^)=]+)\s*\)?(?:\s*=>)/;
5+
var FN_ARGS = /^(?:async\s)?(?:function)?\s*(?:\w+\s*)?\(([^)]+)\)(?:\s*{)/;
6+
var ARROW_FN_ARGS = /^(?:async\s)?\s*(?:\(\s*)?((?:[^)=\s]\s*)*)(?:\)\s*)?=>/;
77
var FN_ARG_SPLIT = /,/;
88
var FN_ARG = /(=.+)?(\s*)$/;
99

0 commit comments

Comments
 (0)