@@ -14,6 +14,7 @@ var Promise = require('promise');
1414var URL = require ( 'url' ) ;
1515var options = require ( './options' )
1616var packageJson = require ( './package.json' )
17+ const shellescape = require ( 'shell-escape' ) ;
1718
1819var regexParseProjectName = / ( .+ : \/ \/ .+ ?\/ | .+ : ) ( .+ \/ [ ^ \. ] + ) + ( \. g i t ) ? / ;
1920
@@ -56,7 +57,7 @@ function getMergeRequestTitle(title) {
5657
5758 exec ( 'git rev-parse --show-toplevel' , function ( error , repoDir /*, stderr*/ ) {
5859 var filePath = repoDir . trim ( ) + '/.git/PULL_REQUEST_TITLE' ;
59- exec ( 'git log -1 --pretty=%B > ' + filePath , function ( /*error, remote, stderr*/ ) {
60+ exec ( 'git log -1 --pretty=%B > ' + shellescape ( [ filePath ] ) , function ( /*error, remote, stderr*/ ) {
6061 exec ( 'git config core.editor' , function ( error , gitEditor /*, stderr*/ ) {
6162 editor ( filePath , { editor : gitEditor . trim ( ) || null } , function ( /*code, sig*/ ) {
6263 fs . readFile ( filePath , 'utf8' , function ( err , data ) {
@@ -171,8 +172,8 @@ function getRemoteForBranch(branchName) {
171172 resolve ( branchRemoteInfo . remote ) ;
172173 } else {
173174 //Remote info is not supplied. Get it from remote set
174- logger . log ( 'Executing git config branch.' + branchName . trim ( ) + '.remote' ) ;
175- exec ( 'git config branch.' + branchName . trim ( ) + '.remote' , { cwd : projectDir } , function ( error , remote /*, stderr*/ ) {
175+ logger . log ( 'Executing git config branch.' + shellescape ( [ branchName . trim ( ) ] ) + '.remote' ) ;
176+ exec ( 'git config branch.' + shellescape ( [ branchName . trim ( ) ] ) + '.remote' , { cwd : projectDir } , function ( error , remote /*, stderr*/ ) {
176177 if ( error ) {
177178 console . error ( colors . red ( 'Error occured while getting remote of the branch: ' , branchName , '\n' ) ) ;
178179 console . log ( '\n\nSet the remote tracking by `git branch --set-upstream-to=origin/' + branchName + '`. Assuming origin is your remote.' ) ;
@@ -194,7 +195,7 @@ function getURLOfRemote(remote) {
194195 logger . log ( '\nGetting URL of remote : ' + remote ) ;
195196 var promise = new Promise ( function ( resolve /*, reject*/ ) {
196197 logger . log ( 'Executing ' , 'git config remote.' + remote . trim ( ) + '.url' ) ;
197- exec ( 'git config remote.' + remote . trim ( ) + '.url' , { cwd : projectDir } , function ( error , remoteURL /*, stderr*/ ) {
198+ exec ( 'git config remote.' + shellescape ( [ remote . trim ( ) ] ) + '.url' , { cwd : projectDir } , function ( error , remoteURL /*, stderr*/ ) {
198199 if ( error ) {
199200 console . error ( colors . red ( 'Error occured :\n' ) , colors . red ( error ) ) ;
200201
0 commit comments