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

Fixed code execution on git-commit-range #1

Merged
merged 2 commits into from
Jul 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@ import isGit from 'is-git-repository';
import { platform } from 'os';
import makepath from 'path';
import pathIsAbsolute from 'path-is-absolute';
import shellescape from 'shell-escape';

const cwd = process.cwd();

var escapeShell = function(cmd) {
if(cmd !== undefined){
var arg = cmd.toString().split(" ");
return shellescape(arg);
}
}

const getCommitRange = (options = {}) => {
const {
path,
Expand All @@ -29,6 +37,11 @@ const getCommitRange = (options = {}) => {
let getCommits;

thisPath = pathIsAbsolute(thisPath) ? thisPath : makepath.join(cwd, thisPath);

// escaping bad shell arguments
thisPath = escapeShell(thisPath);
thisFrom = escapeShell(thisFrom);
thisTo = escapeShell(thisTo);

if (!isGit(thisPath)) {
return [];
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"execa": "^0.7.0",
"is-git-repository": "^1.1.1",
"os": "^0.1.1",
"path-is-absolute": "^1.0.1"
"path-is-absolute": "^1.0.1",
"shell-escape": "^0.2.0"
},
"devDependencies": {
"@babel/cli": "^7.8.4",
Expand Down