Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Commit 9aaa95e

Browse files
authored
fixed the code execution bug
1 parent ad8b3b8 commit 9aaa95e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,27 @@ import isGit from 'is-git-repository';
33
import { platform } from 'os';
44
import makepath from 'path';
55
import pathIsAbsolute from 'path-is-absolute';
6+
import shellescape from 'shell-escape';
67

78
const cwd = process.cwd();
89

10+
// escape bad arguments
11+
var escapeShell = function(cmd) {
12+
if(cmd !== undefined){
13+
var arg = cmd.toString().split(" ");
14+
return shellescape(arg);
15+
}
16+
}
17+
918
const countGitTags = ({ path, local } = {}) => {
1019
let countOfTags = 0;
1120

1221
let thisPath = path || cwd;
1322
thisPath = pathIsAbsolute(thisPath) ? thisPath : makepath.join(cwd, thisPath);
1423
const thisLocal = local === undefined ? true : local;
24+
25+
thisPath = escapeShell(thisPath);
26+
thisLocal = escapeShell(thisLocal);
1527

1628
if (!isGit(thisPath)) {
1729
return 0;

0 commit comments

Comments
 (0)