Skip to content

Commit 640d391

Browse files
committed
fix: fix escaping bug introduced by backtracking
1 parent bff0c87 commit 640d391

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/util/escape.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ function escapeArgument(arg, doubleEscapeMetaChars) {
2020

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

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

3030
// All other backslashes occur literally
3131

0 commit comments

Comments
 (0)