diff options
author | Andre Arko <andre@arko.net> | 2011-06-08 17:01:11 -0700 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2011-06-08 17:01:51 -0700 |
commit | 47943277ed39156053ecfb7b2a59aa31cc2f6ea9 (patch) | |
tree | 32e63ca5bac7f793b19349f7427b868f64a33efa /lib | |
parent | dab97111b5450e4c71f1b6b22156ee57c498984f (diff) | |
download | bundler-47943277ed39156053ecfb7b2a59aa31cc2f6ea9.tar.gz |
escape git URIs correctly on Windows
closes #1212
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bundler/source.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb index 581b2e65..f18ace20 100644 --- a/lib/bundler/source.rb +++ b/lib/bundler/source.rb @@ -608,11 +608,17 @@ module Bundler Digest::SHA1.hexdigest(input) end - # Escape the URI for shell commands. To support a single quote - # within the URI we must end the string, escape the quote and - # restart. + # Escape the URI for git commands def uri_escaped - "'#{uri.gsub("'") {|s| "'\\''"}}'" + if Bundler::WINDOWS + # Windows quoting requires double quotes only, with double quotes + # inside the string escaped by being doubled. + '"' + uri.gsub('"') {|s| '""'} + '"' + else + # Bash requires single quoted strings, with the single quotes escaped + # by ending the string, escaping the quote, and restarting the string. + "'" + uri.gsub("'") {|s| "'\\''"} + "'" + end end def cache_path |