Project

General

Profile

« Previous | Next » 

Revision 852

Quote subversion username and password in svn commands.

View differences:

trunk/lib/redmine/scm/adapters/abstract_adapter.rb
81 81
          path ||= ''
82 82
          (path[0,1]!="/") ? "/#{path}" : path
83 83
        end
84
        
85
        def shell_quote(str)
86
          if RUBY_PLATFORM =~ /mswin/
87
            '"' + str.gsub(/"/, '\\"') + '"'
88
          else
89
            "'" + str.gsub(/'/, "'\"'\"'") + "'"
90
          end
91
        end
84 92
              
85 93
      private
86 94
        def retrieve_root_url
trunk/lib/redmine/scm/adapters/subversion_adapter.rb
29 29
        # Get info about the svn repository
30 30
        def info
31 31
          cmd = "#{SVN_BIN} info --xml #{target('')}"
32
          cmd << " --username #{@login} --password #{@password}" if @login
32
          cmd << credentials_string
33 33
          info = nil
34 34
          shellout(cmd) do |io|
35 35
            begin
......
65 65
          identifier = 'HEAD' unless identifier and identifier > 0
66 66
          entries = Entries.new
67 67
          cmd = "#{SVN_BIN} list --xml #{target(path)}@#{identifier}"
68
          cmd << " --username #{@login} --password #{@password}" if @login
68
          cmd << credentials_string
69 69
          cmd << " 2>&1"
70 70
          shellout(cmd) do |io|
71 71
            output = io.read
......
101 101
          identifier_to = 1 unless identifier_to and identifier_to.to_i > 0
102 102
          revisions = Revisions.new
103 103
          cmd = "#{SVN_BIN} log --xml -r #{identifier_from}:#{identifier_to}"
104
          cmd << " --username #{@login} --password #{@password}" if @login
104
          cmd << credentials_string
105 105
          cmd << " --verbose " if  options[:with_paths]
106 106
          cmd << target(path)
107 107
          shellout(cmd) do |io|
......
145 145
          cmd << "#{identifier_to}:"
146 146
          cmd << "#{identifier_from}"
147 147
          cmd << "#{target(path)}@#{identifier_from}"
148
          cmd << " --username #{@login} --password #{@password}" if @login
148
          cmd << credentials_string
149 149
          diff = []
150 150
          shellout(cmd) do |io|
151 151
            io.each_line do |line|
......
161 161
        def cat(path, identifier=nil)
162 162
          identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD"
163 163
          cmd = "#{SVN_BIN} cat #{target(path)}@#{identifier}"
164
          cmd << " --username #{@login} --password #{@password}" if @login
164
          cmd << credentials_string
165 165
          cat = nil
166 166
          shellout(cmd) do |io|
167 167
            io.binmode
......
172 172
        rescue Errno::ENOENT => e
173 173
          raise CommandFailed    
174 174
        end
175
        
176
        private
177
        
178
        def credentials_string
179
          str = ''
180
          str << " --username #{shell_quote(@login)}" unless @login.blank?
181
          str << " --password #{shell_quote(@password)}" unless @login.blank? || @password.blank?
182
          str
183
        end
175 184
      end
176 185
    end
177 186
  end

Also available in: Unified diff