Skip to content

Commit

Permalink
Escape parentheses in filenames (mattijs#41)
Browse files Browse the repository at this point in the history
* Escape parentheses in filenames

* Fix formatting
  • Loading branch information
LukasLeppich authored and Mattijs Hoitink committed Sep 11, 2016
1 parent dc845e5 commit c03e554
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rsync.js
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ function escapeShellArg(arg) {
* @return {String} the escaped version of the filename
*/
function escapeFileArg(filename) {
return filename.replace(/(["'`\s\\])/g,'\\$1');
return filename.replace(/(["'`\s\\\(\)])/g,'\\$1');
}

/**
Expand Down
8 changes: 8 additions & 0 deletions tests/input.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ describe('input', function () {
assertOutputPattern(rsync, / a_quoted\\'filename\\".txt /);
});

it('should have parentheses escaped', function () {
rsync = Rsync.build({
source: [ 'a (file) with parantheses.txt' ],
destination: 'themoon'
});
assertOutputPattern(rsync, /a\\ \\\(file\\\)\\ with\\ parantheses.txt/);
});

it('should allow mixed filenames', function () {
rsync = Rsync.build({
source: [
Expand Down

0 comments on commit c03e554

Please sign in to comment.