Skip to content

Commit

Permalink
Users/kej/handlebackslashproperly (#6288) (#6289)
Browse files Browse the repository at this point in the history
* Fix for the backslash escaping issue in cURL

* Corrected minor version

* Added comment to explain why we are escaping the backslash character in linux environments
  • Loading branch information
keljos authored Jan 25, 2018
1 parent e0f027a commit 44d2464
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions Tasks/cURLUploader/curluploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,13 @@ async function run() {
// Now we get a list of all files under this root
var allFiles = tl.find(findPathRoot);

// IMPORTANT: The backslash character is a valid character in linux style directory and file names. However, as
// this is a file pattern not a file path we are converting all backslashes to forward slashes.
filesPattern = filesPattern.replace(/\\/g, '/');

// Now matching the pattern against all files
var uploadFilesList = tl.match(allFiles, filesPattern, undefined, {matchBase: true});
var uploadFilesList = tl.match(allFiles, filesPattern, undefined, {matchBase: true}).map( (s) => {
// If running on Windows agent, normalize the Windows style file paths to use '/' rather than '\'.
// If running on Linux or macOS, escape any '\' in filenames. This is necessary as curl.exe treats
// '\' in filenames as escape characters, preventing it from finding those files.
return isWin ? s.replace(/\\/g, '/') : s.replace(/\\/g, '\\\\');
});

// Fail if no matching app files were found
if (!uploadFilesList || uploadFilesList.length == 0) {
Expand Down
2 changes: 1 addition & 1 deletion Tasks/cURLUploader/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 127,
"Minor": 130,
"Patch": 0
},
"runsOn": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/cURLUploader/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 127,
"Minor": 130,
"Patch": 0
},
"runsOn": [
Expand Down

0 comments on commit 44d2464

Please sign in to comment.