Skip to content

Commit cca7109

Browse files
committed
Properly escape Windows command line arguments
Signed-off-by: James Couball <jcouball@yahoo.com>
1 parent 934d17d commit cca7109

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/git/lib.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,8 +1191,9 @@ def escape_for_sh(s)
11911191
end
11921192

11931193
def escape_for_windows(s)
1194-
# Windows does not need single quote escaping inside double quotes
1195-
%Q{"#{s}"}
1194+
# Escape existing double quotes in s and then wrap the result with double quotes
1195+
escaped_string = s.to_s.gsub('"','\\"')
1196+
%Q{"#{escaped_string}"}
11961197
end
11971198

11981199
def windows_platform?

0 commit comments

Comments
 (0)