GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: disable regexp backtracking (#160) · moxystudio/node-cross-spawn@ba5aaef

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/util
    • escape.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/util/escape.js‎

Copy file name to clipboardExpand all lines: lib/util/escape.js
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@ 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
1820

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

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

2830
// All other backslashes occur literally
2931

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.