Skip to content

Commit

Permalink
Properly escape Windows command line arguments
Browse files Browse the repository at this point in the history
Signed-off-by: James Couball <jcouball@yahoo.com>
  • Loading branch information
jcouball committed Jan 3, 2022
1 parent 934d17d commit cca7109
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/git/lib.rb
Expand Up @@ -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?
Expand Down

0 comments on commit cca7109

Please sign in to comment.