From 8e2ff51e45b77828e506fc806c071ee2cb2baba1 Mon Sep 17 00:00:00 2001 From: stefansli <104021830+stefansli@users.noreply.github.com> Date: Tue, 7 May 2024 15:28:26 +0200 Subject: [PATCH] Ensure backslashes in windows filename (#1555) cmd.exe doesn't work with '/' as path separator. Co-authored-by: Mark Waite --- .../java/jenkins/plugins/git/GitUsernamePasswordBinding.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/jenkins/plugins/git/GitUsernamePasswordBinding.java b/src/main/java/jenkins/plugins/git/GitUsernamePasswordBinding.java index a0ee7e3161..abe7acfd52 100644 --- a/src/main/java/jenkins/plugins/git/GitUsernamePasswordBinding.java +++ b/src/main/java/jenkins/plugins/git/GitUsernamePasswordBinding.java @@ -193,7 +193,8 @@ private String windowsArgEncodeFileName(String filename) { if (filename.contains("\"")) { filename = filename.replace("\"", "^\""); } - return "\"" + filename + "\""; + /* Ensure backslashes since cmd doesn't work with slashes as path separators */ + return "\"" + filename.replace("/", "\\") + "\""; } }