Skip to content

Commit

Permalink
Fix ReDoS (#1980)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
kevinbackhouse authored Aug 8, 2024
1 parent 39cdc9b commit 5f756b4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/autoInject.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import auto from './auto.js'
import wrapAsync from './internal/wrapAsync.js'
import { isAsync } from './internal/wrapAsync.js'

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

Expand Down

0 comments on commit 5f756b4

Please sign in to comment.