Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11351: plugin_install_from_secure_repository.patch

File plugin_install_from_secure_repository.patch, 1.1 kB (added by david.calavera, 6 months ago)

it also fixes the same bug with the list command

  • railties/lib/commands/plugin.rb

    old new  
    893893      if url =~ /^svn:\/\/.*/ 
    894894        `svn ls #{url}`.split("\n").map {|entry| "/#{entry}"} rescue nil 
    895895      else 
    896         open(url) do |stream| 
     896        open(url, add_credentials(url)) do |stream| 
    897897          links("", stream.read) 
    898898        end rescue nil 
    899899      end 
     
    938938  def fetch_dir(url) 
    939939    @level += 1 
    940940    push_d(File.basename(url)) if @level > 0 
    941     open(url) do |stream| 
     941    open(url, add_credentials(url)) do |stream| 
    942942      contents =  stream.read 
    943943      fetch(links(url, contents)) 
    944944    end 
    945945    pop_d if @level > 0 
    946946    @level -= 1 
    947947  end 
     948   
     949  def add_credentials(url) 
     950    uri = URI.parse(url) 
     951     raise ArgumentError, 'url is not an HTTP URI' unless URI::HTTP 
     952     
     953    {:http_basic_authentication => [URI.unescape(uri.user), 
     954      URI.unescape(uri.password)]} unless uri.nil? || uri.user.nil? || uri.user.empty? 
     955  end 
    948956end 
    949957 
    950958Commands::Plugin.parse!