Skip to content

Commit f33d165

Browse files
committed
Revert "escape spaces in sudo commands (fix #123)"
This reverts commit 9988b3e.
1 parent 4a6f83f commit f33d165

File tree

4 files changed

+2
-28
lines changed

4 files changed

+2
-28
lines changed

lib/transport/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var format = require('util').format
77
, errors = require('../errors')
88
, commands = require('./commands')
99
, queue = require('../utils/queue')
10-
, utils = require('../utils');
10+
, escapeSingleQuotes = require('../utils').escapeSingleQuotes;
1111

1212
/**
1313
* A transport is the interface you use during flights. Basically they
@@ -190,8 +190,7 @@ Transport.prototype.sudo = function(command, options) {
190190
var user = options.user || 'root';
191191

192192
command = format('%s%s', this._execWith, command);
193-
command = utils.escapeSingleQuotes(command);
194-
command = utils.escapeSpaces(command);
193+
command = escapeSingleQuotes(command);
195194
command = format("sudo -u %s -i bash -c '%s'", user, command);
196195

197196
return this._exec(command, options);

lib/utils/index.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,3 @@ exports.escapeSingleQuotes = function(str) {
2424

2525
return str.replace(/'/g, "'\\''");
2626
};
27-
28-
exports.escapeSpaces = function(str) {
29-
if(!str) {
30-
return str;
31-
}
32-
33-
return str.replace(/ /g, '\\ ');
34-
};

test/test.transport.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,6 @@ describe('transport', function() {
112112
transport.sudo("'cmd'");
113113

114114
expect(transport._exec.lastCall.args[0]).to.equal("sudo -u root -i bash -c ''\\''cmd'\\'''");
115-
116-
transport.sudo(' a b c ');
117-
118-
expect(transport._exec.lastCall.args[0]).to.contain('\\ a\\ \\ b\\ c\\ ');
119115
});
120116

121117
it('should pass options to #_exec()', function() {

test/test.utils.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,6 @@ describe('utils', function() {
4545
expect(escapeSingleQuotes('"string"')).to.equal('"string"');
4646
expect(escapeSingleQuotes("\\'string\\'")).to.equal("\\'\\''string\\'\\''");
4747
expect(escapeSingleQuotes('')).to.equal('');
48-
expect(escapeSingleQuotes()).to.be.undefined;
49-
});
50-
});
51-
52-
describe('#escapeSpaces()', function() {
53-
it('should correctly escape single quotes', function() {
54-
var escapeSpaces = proxyquire('../lib/utils', {}).escapeSpaces;
55-
56-
expect(escapeSpaces('str str')).to.equal('str\\ str');
57-
expect(escapeSpaces(' str ')).to.equal('\\ str\\ \\ ');
58-
expect(escapeSpaces('str str')).to.equal('str\\ \\ str');
59-
expect(escapeSpaces('')).to.equal('');
60-
expect(escapeSpaces()).to.be.undefined;
6148
});
6249
});
6350

0 commit comments

Comments
 (0)