From e417446f599d1bfd85c5d56b8acc5e34f51a6e42 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Tue, 4 Jan 2022 00:01:26 -0500 Subject: [PATCH] Fixes #1645 - removes regex Possible catastrophic backtracking with large inputs (very unlikely in the wild) --- src/env/node/git/locator.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/env/node/git/locator.ts b/src/env/node/git/locator.ts index bb544f4..b471f63 100644 --- a/src/env/node/git/locator.ts +++ b/src/env/node/git/locator.ts @@ -70,12 +70,8 @@ async function findSpecificGit(path: string): Promise { async function findGitDarwin(): Promise { try { - let path = await run('which', ['git'], 'utf8'); - path = path.replace(/^\s+|\s+$/g, ''); - - if (path !== '/usr/bin/git') { - return findSpecificGit(path); - } + const path = (await run('which', ['git'], 'utf8')).trim(); + if (path !== '/usr/bin/git') return findSpecificGit(path); try { await run('xcode-select', ['-p'], 'utf8');