From 86b132b1843a13cbe209949d6a7d935f9d7bd9fa Mon Sep 17 00:00:00 2001 From: kelliejos <31480321+kelliejos@users.noreply.github.com> Date: Thu, 25 Jan 2018 15:42:09 -0500 Subject: [PATCH] Users/kej/handlebackslashproperly (#6288) * 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 --- Tasks/cURLUploader/curluploader.ts | 11 ++++++----- Tasks/cURLUploader/task.json | 2 +- Tasks/cURLUploader/task.loc.json | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Tasks/cURLUploader/curluploader.ts b/Tasks/cURLUploader/curluploader.ts index a78474e89907..c7113cb34480 100644 --- a/Tasks/cURLUploader/curluploader.ts +++ b/Tasks/cURLUploader/curluploader.ts @@ -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) { diff --git a/Tasks/cURLUploader/task.json b/Tasks/cURLUploader/task.json index 41e499b3140b..b8fa0b65bbd9 100644 --- a/Tasks/cURLUploader/task.json +++ b/Tasks/cURLUploader/task.json @@ -8,7 +8,7 @@ "author": "Microsoft Corporation", "version": { "Major": 2, - "Minor": 127, + "Minor": 130, "Patch": 0 }, "runsOn": [ diff --git a/Tasks/cURLUploader/task.loc.json b/Tasks/cURLUploader/task.loc.json index b64377fcf1e5..6fe17d0176c2 100644 --- a/Tasks/cURLUploader/task.loc.json +++ b/Tasks/cURLUploader/task.loc.json @@ -8,7 +8,7 @@ "author": "Microsoft Corporation", "version": { "Major": 2, - "Minor": 127, + "Minor": 130, "Patch": 0 }, "runsOn": [