Skip to content

Commit 31c1712

Browse files
committed
Revert "fix: disable regexp backtracking (#160)"
This reverts commit 5ff3a07.
1 parent ccbaa82 commit 31c1712

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

lib/util/escape.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,15 @@ function escapeArgument(arg, doubleEscapeMetaChars) {
1515
arg = `${arg}`;
1616

1717
// Algorithm below is based on https://qntm.org/cmd
18-
// It's slightly altered to disable JS backtracking to avoid hanging on specially crafted input
19-
// Please see https://github.com/moxystudio/node-cross-spawn/pull/160 for more information
2018

2119
// Sequence of backslashes followed by a double quote:
2220
// double up all the backslashes and escape the double quote
23-
arg = arg.replace(/(?=\\*?)"/g, '$1$1\\"');
21+
arg = arg.replace(/(\\*)"/g, '$1$1\\"');
2422

2523
// Sequence of backslashes followed by the end of the string
2624
// (which will become a double quote later):
2725
// double up all the backslashes
28-
arg = arg.replace(/(?=\\*?)$/, '$1$1');
26+
arg = arg.replace(/(\\*)$/, '$1$1');
2927

3028
// All other backslashes occur literally
3129

0 commit comments

Comments
 (0)