Quote subversion username and password in svn commands.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@852 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
0006c5f3b0
commit
ecfc40629f
@ -81,6 +81,14 @@ module Redmine
|
|||||||
path ||= ''
|
path ||= ''
|
||||||
(path[0,1]!="/") ? "/#{path}" : path
|
(path[0,1]!="/") ? "/#{path}" : path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def shell_quote(str)
|
||||||
|
if RUBY_PLATFORM =~ /mswin/
|
||||||
|
'"' + str.gsub(/"/, '\\"') + '"'
|
||||||
|
else
|
||||||
|
"'" + str.gsub(/'/, "'\"'\"'") + "'"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def retrieve_root_url
|
def retrieve_root_url
|
||||||
|
@ -29,7 +29,7 @@ module Redmine
|
|||||||
# Get info about the svn repository
|
# Get info about the svn repository
|
||||||
def info
|
def info
|
||||||
cmd = "#{SVN_BIN} info --xml #{target('')}"
|
cmd = "#{SVN_BIN} info --xml #{target('')}"
|
||||||
cmd << " --username #{@login} --password #{@password}" if @login
|
cmd << credentials_string
|
||||||
info = nil
|
info = nil
|
||||||
shellout(cmd) do |io|
|
shellout(cmd) do |io|
|
||||||
begin
|
begin
|
||||||
@ -65,7 +65,7 @@ module Redmine
|
|||||||
identifier = 'HEAD' unless identifier and identifier > 0
|
identifier = 'HEAD' unless identifier and identifier > 0
|
||||||
entries = Entries.new
|
entries = Entries.new
|
||||||
cmd = "#{SVN_BIN} list --xml #{target(path)}@#{identifier}"
|
cmd = "#{SVN_BIN} list --xml #{target(path)}@#{identifier}"
|
||||||
cmd << " --username #{@login} --password #{@password}" if @login
|
cmd << credentials_string
|
||||||
cmd << " 2>&1"
|
cmd << " 2>&1"
|
||||||
shellout(cmd) do |io|
|
shellout(cmd) do |io|
|
||||||
output = io.read
|
output = io.read
|
||||||
@ -101,7 +101,7 @@ module Redmine
|
|||||||
identifier_to = 1 unless identifier_to and identifier_to.to_i > 0
|
identifier_to = 1 unless identifier_to and identifier_to.to_i > 0
|
||||||
revisions = Revisions.new
|
revisions = Revisions.new
|
||||||
cmd = "#{SVN_BIN} log --xml -r #{identifier_from}:#{identifier_to}"
|
cmd = "#{SVN_BIN} log --xml -r #{identifier_from}:#{identifier_to}"
|
||||||
cmd << " --username #{@login} --password #{@password}" if @login
|
cmd << credentials_string
|
||||||
cmd << " --verbose " if options[:with_paths]
|
cmd << " --verbose " if options[:with_paths]
|
||||||
cmd << target(path)
|
cmd << target(path)
|
||||||
shellout(cmd) do |io|
|
shellout(cmd) do |io|
|
||||||
@ -145,7 +145,7 @@ module Redmine
|
|||||||
cmd << "#{identifier_to}:"
|
cmd << "#{identifier_to}:"
|
||||||
cmd << "#{identifier_from}"
|
cmd << "#{identifier_from}"
|
||||||
cmd << "#{target(path)}@#{identifier_from}"
|
cmd << "#{target(path)}@#{identifier_from}"
|
||||||
cmd << " --username #{@login} --password #{@password}" if @login
|
cmd << credentials_string
|
||||||
diff = []
|
diff = []
|
||||||
shellout(cmd) do |io|
|
shellout(cmd) do |io|
|
||||||
io.each_line do |line|
|
io.each_line do |line|
|
||||||
@ -161,7 +161,7 @@ module Redmine
|
|||||||
def cat(path, identifier=nil)
|
def cat(path, identifier=nil)
|
||||||
identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD"
|
identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD"
|
||||||
cmd = "#{SVN_BIN} cat #{target(path)}@#{identifier}"
|
cmd = "#{SVN_BIN} cat #{target(path)}@#{identifier}"
|
||||||
cmd << " --username #{@login} --password #{@password}" if @login
|
cmd << credentials_string
|
||||||
cat = nil
|
cat = nil
|
||||||
shellout(cmd) do |io|
|
shellout(cmd) do |io|
|
||||||
io.binmode
|
io.binmode
|
||||||
@ -172,6 +172,15 @@ module Redmine
|
|||||||
rescue Errno::ENOENT => e
|
rescue Errno::ENOENT => e
|
||||||
raise CommandFailed
|
raise CommandFailed
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def credentials_string
|
||||||
|
str = ''
|
||||||
|
str << " --username #{shell_quote(@login)}" unless @login.blank?
|
||||||
|
str << " --password #{shell_quote(@password)}" unless @login.blank? || @password.blank?
|
||||||
|
str
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user