From 4e53f3ad72d16ec251ba92233ce4757a3bc13618 Mon Sep 17 00:00:00 2001 From: hsbt Date: Thu, 28 Apr 2016 00:33:08 +0000 Subject: * lib/rubygems.rb, lib/rubygems/*, test/rubygems/*: Update rubygems-2.6.4. Please see entries of 2.6.4 on https://github.com/rubygems/rubygems/blob/master/History.txt git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54804 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++ lib/rubygems.rb | 2 +- lib/rubygems/commands/query_command.rb | 2 +- lib/rubygems/errors.rb | 1 + lib/rubygems/installer.rb | 9 ++--- lib/rubygems/remote_fetcher.rb | 8 ++++- lib/rubygems/server.rb | 46 ++++++++++++-------------- lib/rubygems/user_interaction.rb | 12 +++---- test/rubygems/rubygems_plugin.rb | 4 +++ test/rubygems/test_gem_installer.rb | 27 ++++++++++++--- test/rubygems/test_gem_source_fetch_problem.rb | 8 +++++ test/rubygems/test_remote_fetch_error.rb | 21 ++++++++++++ 12 files changed, 101 insertions(+), 45 deletions(-) create mode 100644 test/rubygems/test_remote_fetch_error.rb diff --git a/ChangeLog b/ChangeLog index 5cf25f9217..b44e60f762 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu Apr 28 09:33:03 2016 SHIBATA Hiroshi + + * lib/rubygems.rb, lib/rubygems/*, test/rubygems/*: Update rubygems-2.6.4. + Please see entries of 2.6.4 on + https://github.com/rubygems/rubygems/blob/master/History.txt + Thu Apr 28 04:49:07 2016 Rei Odaira * configure.in (rb_cv_lgamma_r_pm0): check if lgamma_r(+0.0) diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 78d612af63..e6cc859cbe 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -10,7 +10,7 @@ require 'rbconfig' require 'thread' module Gem - VERSION = '2.6.3' + VERSION = '2.6.4' end # Must be first since it unloads the prelude from 1.9.2 diff --git a/lib/rubygems/commands/query_command.rb b/lib/rubygems/commands/query_command.rb index fb2d6a53c8..f25d120b88 100644 --- a/lib/rubygems/commands/query_command.rb +++ b/lib/rubygems/commands/query_command.rb @@ -259,7 +259,7 @@ is too hard to use. if options[:domain] == :remote || specs.all? { |spec| spec.is_a? Gem::Source } version else - spec = specs.select { |spec| spec.version == version } + spec = specs.select { |s| s.version == version } if spec.first.default_gem? "default: #{version}" else diff --git a/lib/rubygems/errors.rb b/lib/rubygems/errors.rb index f607d14938..5cd5b14c58 100644 --- a/lib/rubygems/errors.rb +++ b/lib/rubygems/errors.rb @@ -170,6 +170,7 @@ module Gem # An English description of the error. def wordy + @source.uri.password = 'REDACTED' unless @source.uri.password.nil? "Unable to download data from #{@source.uri} - #{@error.message}" end diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb index 1813c9a27d..3269179200 100644 --- a/lib/rubygems/installer.rb +++ b/lib/rubygems/installer.rb @@ -509,12 +509,6 @@ class Gem::Installer # the symlink if the gem being installed has a newer version. def generate_bin_symlink(filename, bindir) - if Gem.win_platform? then - alert_warning "Unable to use symlinks on Windows, installing wrapper" - generate_bin_script filename, bindir - return - end - src = File.join gem_dir, spec.bindir, filename dst = File.join bindir, formatted_program_filename(filename) @@ -528,6 +522,9 @@ class Gem::Installer end FileUtils.symlink src, dst, :verbose => Gem.configuration.really_verbose + rescue NotImplementedError, SystemCallError + alert_warning "Unable to use symlinks, installing wrapper" + generate_bin_script filename, bindir end ## diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb index fda1e067ef..a2d8ba45e3 100644 --- a/lib/rubygems/remote_fetcher.rb +++ b/lib/rubygems/remote_fetcher.rb @@ -27,7 +27,13 @@ class Gem::RemoteFetcher def initialize(message, uri) super message - @uri = uri + begin + uri = URI(uri) + uri.password = 'REDACTED' if uri.password + @uri = uri.to_s + rescue URI::InvalidURIError, ArgumentError + @uri = uri + end end def to_s # :nodoc: diff --git a/lib/rubygems/server.rb b/lib/rubygems/server.rb index 8d6a96b1c2..63dfe31b35 100644 --- a/lib/rubygems/server.rb +++ b/lib/rubygems/server.rb @@ -34,7 +34,7 @@ class Gem::Server include ERB::Util include Gem::UserInteraction - SEARCH = <<-SEARCH + SEARCH = <<-ERB
- SEARCH + ERB - DOC_TEMPLATE = <<-'DOC_TEMPLATE' + DOC_TEMPLATE = <<-'ERB' Summary

There are <%=values["gem_count"]%> gems installed:

- <%= values["specs"].map { |v| "#{v["name"]}" }.join ', ' %>. + <%= values["specs"].map { |v| "#{h v["name"]}" }.join ', ' %>.

Gems

<% values["specs"].each do |spec| %>
<% if spec["first_name_entry"] then %> - "> + "> <% end %> - <%=spec["name"]%> <%=spec["version"]%> + <%=h spec["name"]%> <%=h spec["version"]%> - <% if spec["ri_installed"] then %> - ">[rdoc] - <% elsif spec["rdoc_installed"] then %> - ">[rdoc] + <% if spec["ri_installed"] || spec["rdoc_installed"] then %> + ">[rdoc] <% else %> [rdoc] <% end %> <% if spec["homepage"] then %> - " title="<%=spec["homepage"]%>">[www] + " title="<%=h spec["homepage"]%>">[www] <% else %> [www] <% end %> <% if spec["has_deps"] then %> - depends on - <%= spec["dependencies"].map { |v| "#{v["name"]}" }.join ', ' %>. + <%= spec["dependencies"].map { |v| "#{h v["name"]}" }.join ', ' %>. <% end %>
@@ -110,7 +108,7 @@ class Gem::Server Executables are <%end%> - <%= spec["executables"].map { |v| "#{v["executable"]}"}.join ', ' %>. + <%= spec["executables"].map { |v| "#{h v["executable"]}"}.join ', ' %>. <%end%>
@@ -127,10 +125,10 @@ class Gem::Server - DOC_TEMPLATE + ERB # CSS is copy & paste from rdoc-style.css, RDoc V1.0.1 - 20041108 - RDOC_CSS = <<-RDOC_CSS + RDOC_CSS = <<-CSS body { font-family: Verdana,Arial,Helvetica,sans-serif; font-size: 90%; @@ -338,9 +336,9 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; } .ruby-comment { color: #b22222; font-weight: bold; background: transparent; } .ruby-regexp { color: #ffa07a; background: transparent; } .ruby-value { color: #7fffd4; background: transparent; } - RDOC_CSS + CSS - RDOC_NO_DOCUMENTATION = <<-'NO_DOC' + RDOC_NO_DOCUMENTATION = <<-'ERB' @@ -372,9 +370,9 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; } - NO_DOC + ERB - RDOC_SEARCH_TEMPLATE = <<-'RDOC_SEARCH' + RDOC_SEARCH_TEMPLATE = <<-'ERB' @@ -401,10 +399,10 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; } <% doc_items.each do |doc_item| %>
<%=doc_item[:name]%> - [rdoc] + [rdoc]
- <%=doc_item[:summary]%> + <%=h doc_item[:summary]%>

@@ -423,7 +421,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; } - RDOC_SEARCH + ERB def self.run(options) new(options[:gemdir], options[:port], options[:daemon], @@ -459,9 +457,9 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; } def doc_root gem_name if have_rdoc_4_plus? then - "/doc_root/#{gem_name}/" + "/doc_root/#{u gem_name}/" else - "/doc_root/#{gem_name}/rdoc/index.html" + "/doc_root/#{u gem_name}/rdoc/index.html" end end diff --git a/lib/rubygems/user_interaction.rb b/lib/rubygems/user_interaction.rb index 6c8534dd55..390d0f2aea 100644 --- a/lib/rubygems/user_interaction.rb +++ b/lib/rubygems/user_interaction.rb @@ -5,6 +5,8 @@ # See LICENSE.txt for permissions. #++ +require 'rubygems/util' + begin require 'io/console' rescue LoadError @@ -676,13 +678,8 @@ class Gem::SilentUI < Gem::StreamUI def initialize reader, writer = nil, nil - begin - reader = File.open('/dev/null', 'r') - writer = File.open('/dev/null', 'w') - rescue Errno::ENOENT - reader = File.open('nul', 'r') - writer = File.open('nul', 'w') - end + reader = File.open(Gem::Util::NULL_DEVICE, 'r') + writer = File.open(Gem::Util::NULL_DEVICE, 'w') super reader, writer, writer, false end @@ -701,4 +698,3 @@ class Gem::SilentUI < Gem::StreamUI SilentProgressReporter.new(@outs, *args) end end - diff --git a/test/rubygems/rubygems_plugin.rb b/test/rubygems/rubygems_plugin.rb index 0195a2139a..30a67789c6 100644 --- a/test/rubygems/rubygems_plugin.rb +++ b/test/rubygems/rubygems_plugin.rb @@ -6,6 +6,10 @@ require 'rubygems/command_manager' # # DO NOT include code like this in your rubygems_plugin.rb +module Gem::Commands + remove_const(:InterruptCommand) if defined?(InterruptCommand) +end + class Gem::Commands::InterruptCommand < Gem::Command def initialize diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb index f9149650f0..dedb4c99ca 100644 --- a/test/rubygems/test_gem_installer.rb +++ b/test/rubygems/test_gem_installer.rb @@ -2,6 +2,20 @@ require 'rubygems/installer_test_case' class TestGemInstaller < Gem::InstallerTestCase + @@symlink_supported = nil + + def symlink_supported? + if @@symlink_supported.nil? + begin + File.symlink("", "") + rescue Errno::ENOENT, Errno::EEXIST + @@symlink_supported = true + rescue NotImplementedError, SystemCallError + @@symlink_supported = false + end + end + @@symlink_supported + end def setup super @@ -552,7 +566,7 @@ gem 'other', version end def test_generate_bin_symlink_update_older - return if win_platform? #Windows FS do not support symlinks + return if !symlink_supported? @installer.wrappers = false util_make_exec @@ -588,7 +602,7 @@ gem 'other', version end def test_generate_bin_symlink_update_remove_wrapper - return if win_platform? #Windows FS do not support symlinks + return if !symlink_supported? @installer.wrappers = true util_make_exec @@ -639,7 +653,12 @@ gem 'other', version installed_exec = File.join(util_inst_bindir, 'executable') assert_path_exists installed_exec - assert_match(/Unable to use symlinks on Windows, installing wrapper/i, + if symlink_supported? + assert_send([File, :symlink?, installed_exec]) + return + end + + assert_match(/Unable to use symlinks, installing wrapper/i, @ui.error) wrapper = File.read installed_exec @@ -651,7 +670,7 @@ gem 'other', version end def test_generate_bin_uses_default_shebang - return if win_platform? #Windows FS do not support symlinks + return if !symlink_supported? @installer.wrappers = true util_make_exec diff --git a/test/rubygems/test_gem_source_fetch_problem.rb b/test/rubygems/test_gem_source_fetch_problem.rb index 7392a1ef0a..4a245f25df 100644 --- a/test/rubygems/test_gem_source_fetch_problem.rb +++ b/test/rubygems/test_gem_source_fetch_problem.rb @@ -16,5 +16,13 @@ class TestGemSourceFetchProblem < Gem::TestCase assert_equal 'test', e.message end + def test_password_redacted + source = Gem::Source.new 'https://username:secret@gemsource.com' + error = RuntimeError.new 'test' + + sf = Gem::SourceFetchProblem.new source, error + + refute_match sf.wordy, 'secret' + end end diff --git a/test/rubygems/test_remote_fetch_error.rb b/test/rubygems/test_remote_fetch_error.rb new file mode 100644 index 0000000000..6b0f5477d6 --- /dev/null +++ b/test/rubygems/test_remote_fetch_error.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true +require 'rubygems/test_case' + +class TestRemoteFetchError < Gem::TestCase + + def test_password_redacted + error = Gem::RemoteFetcher::FetchError.new('There was an error fetching', 'https://user:secret@gemsource.org') + refute_match error.to_s, 'secret' + end + + def test_invalid_url + error = Gem::RemoteFetcher::FetchError.new('There was an error fetching', 'https://::gemsource.org') + assert_equal error.to_s, 'There was an error fetching (https://::gemsource.org)' + end + + def test_to_s + error = Gem::RemoteFetcher::FetchError.new('There was an error fetching', 'https://gemsource.org') + assert_equal error.to_s, 'There was an error fetching (https://gemsource.org)' + end +end + -- cgit v1.2.3