From beb42b1ffb2fcf8276c3bd5b357ab3893cd5fdae Mon Sep 17 00:00:00 2001 From: James Couball Date: Mon, 3 Jan 2022 08:53:08 -0800 Subject: [PATCH] Properly escape Windows command line arguments Signed-off-by: James Couball --- lib/git/lib.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/git/lib.rb b/lib/git/lib.rb index d892462a..c4ca82c3 100644 --- a/lib/git/lib.rb +++ b/lib/git/lib.rb @@ -1191,8 +1191,9 @@ def escape_for_sh(s) end def escape_for_windows(s) - # Windows does not need single quote escaping inside double quotes - %Q{"#{s}"} + # Escape existing double quotes in s and then wrap the result with double quotes + escaped_string = s.to_s.gsub('"','""') + %Q{"#{escaped_string}"} end def windows_platform?