diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-02-14 06:14:34 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-02-14 06:14:34 +0000 |
commit | 8b98c05879a278cd86fa83c73e5852cad3df4826 (patch) | |
tree | f9811da76083c030cd161214345f0e5c44b14c51 /lib/redmine/scm/adapters/abstract_adapter.rb | |
parent | 8b5ebd92c98a9e4991bec563d9b6b8d42fc35f1c (diff) | |
download | redmine-8b98c05879a278cd86fa83c73e5852cad3df4826.tar.gz redmine-8b98c05879a278cd86fa83c73e5852cad3df4826.zip |
scm: use shell quote for scm command at adapter level (#7517, #4273).
"C:\Program Files\TortoiseHg\hg.exe" can be used in config/configuration.yml.
In Ruby 1.9 IO.popen, if cmd is an Array of String,
it will be used as the subprocess‘s argv bypassing a shell.
See http://www.ruby-doc.org/core/classes/IO.html
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4821 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine/scm/adapters/abstract_adapter.rb')
-rw-r--r-- | lib/redmine/scm/adapters/abstract_adapter.rb | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/lib/redmine/scm/adapters/abstract_adapter.rb b/lib/redmine/scm/adapters/abstract_adapter.rb index f98e90958..3442276b1 100644 --- a/lib/redmine/scm/adapters/abstract_adapter.rb +++ b/lib/redmine/scm/adapters/abstract_adapter.rb @@ -25,6 +25,10 @@ module Redmine class AbstractAdapter #:nodoc: class << self + def client_command + "" + end + # Returns the version of the scm client # Eg: [1, 5, 0] or [] if unknown def client_version @@ -45,8 +49,20 @@ module Redmine def client_version_above?(v, options={}) ((client_version <=> v) >= 0) || (client_version.empty? && options[:unknown]) end + + def client_available + true + end + + def shell_quote(str) + if Redmine::Platform.mswin? + '"' + str.gsub(/"/, '\\"') + '"' + else + "'" + str.gsub(/'/, "'\"'\"'") + "'" + end + end end - + def initialize(url, root_url=nil, login=nil, password=nil) @url = url @login = login if login && !login.empty? @@ -138,7 +154,7 @@ module Redmine path ||= '' (path[-1,1] == "/") ? path : "#{path}/" end - + def without_leading_slash(path) path ||= '' path.gsub(%r{^/+}, '') @@ -148,13 +164,9 @@ module Redmine path ||= '' (path[-1,1] == "/") ? path[0..-2] : path end - + def shell_quote(str) - if Redmine::Platform.mswin? - '"' + str.gsub(/"/, '\\"') + '"' - else - "'" + str.gsub(/'/, "'\"'\"'") + "'" - end + self.class.shell_quote(str) end private @@ -168,11 +180,11 @@ module Redmine base = path.match(/^\//) ? root_url : url shell_quote("#{base}/#{path}".gsub(/[?<>\*]/, '')) end - + def logger self.class.logger end - + def shellout(cmd, &block) self.class.shellout(cmd, &block) end |