diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-08-28 08:31:28 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-08-28 08:31:28 +0000 |
commit | c5da5b1ea27ec693dd09e9d586e913da1d5ba4b6 (patch) | |
tree | 8624c192a757d272b5ebae46dd9691b7994da0c5 /lib | |
parent | 1a1930180c66b291c89d486b984f8bf5237d6918 (diff) | |
download | ruby-c5da5b1ea27ec693dd09e9d586e913da1d5ba4b6.tar.gz |
Merge rubygems-2.6.13.
see details for this update:
http://blog.rubygems.org/2017/08/27/2.6.13-released.html
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rubygems.rb | 2 | ||||
-rw-r--r-- | lib/rubygems/commands/query_command.rb | 5 | ||||
-rw-r--r-- | lib/rubygems/installer.rb | 7 | ||||
-rw-r--r-- | lib/rubygems/remote_fetcher.rb | 2 | ||||
-rw-r--r-- | lib/rubygems/specification.rb | 12 | ||||
-rw-r--r-- | lib/rubygems/text.rb | 15 |
6 files changed, 36 insertions, 7 deletions
diff --git a/lib/rubygems.rb b/lib/rubygems.rb index bc5bf9b4c2..55aa85b8b2 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -10,7 +10,7 @@ require 'rbconfig' require 'thread' module Gem - VERSION = "2.6.12" + VERSION = "2.6.13" 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 70f8127292..44144203e0 100644 --- a/lib/rubygems/commands/query_command.rb +++ b/lib/rubygems/commands/query_command.rb @@ -226,7 +226,7 @@ is too hard to use. end end - output << make_entry(matching_tuples, platforms) + output << clean_text(make_entry(matching_tuples, platforms)) end end @@ -353,7 +353,8 @@ is too hard to use. end def spec_summary entry, spec - entry << "\n\n" << format_text(spec.summary, 68, 4) + summary = truncate_text(spec.summary, "the summary for #{spec.full_name}") + entry << "\n\n" << format_text(summary, 68, 4) end end diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb index 967543c2d1..6fd3399dd4 100644 --- a/lib/rubygems/installer.rb +++ b/lib/rubygems/installer.rb @@ -697,6 +697,11 @@ class Gem::Installer unpack or File.writable?(gem_home) end + def verify_spec_name + return if spec.name =~ Gem::Specification::VALID_NAME_PATTERN + raise Gem::InstallError, "#{spec} has an invalid name" + end + ## # Return the text for an application file. @@ -823,6 +828,8 @@ TEXT ensure_loadable_spec + verify_spec_name + if options[:install_as_default] Gem.ensure_default_gem_subdirectories gem_home else diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb index e6a13d4b8c..8f0cf0b402 100644 --- a/lib/rubygems/remote_fetcher.rb +++ b/lib/rubygems/remote_fetcher.rb @@ -110,7 +110,7 @@ class Gem::RemoteFetcher else target = res.target.to_s.strip - if /\.#{Regexp.quote(host)}\z/ =~ target + if URI("http://" + target).host.end_with?(".#{host}") return URI.parse "#{uri.scheme}://#{target}#{uri.path}" end diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index 4c4564e155..ea3e3ecf2b 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -108,6 +108,8 @@ class Gem::Specification < Gem::BasicSpecification private_constant :LOAD_CACHE if defined? private_constant + VALID_NAME_PATTERN = /\A[a-zA-Z0-9\.\-\_]+\z/ # :nodoc: + # :startdoc: ## @@ -2672,9 +2674,15 @@ class Gem::Specification < Gem::BasicSpecification end end - unless String === name then + if !name.is_a?(String) then + raise Gem::InvalidSpecificationException, + "invalid value for attribute name: \"#{name.inspect}\" must be a string" + elsif name !~ /[a-zA-Z]/ then + raise Gem::InvalidSpecificationException, + "invalid value for attribute name: #{name.dump} must include at least one letter" + elsif name !~ VALID_NAME_PATTERN then raise Gem::InvalidSpecificationException, - "invalid value for attribute name: \"#{name.inspect}\"" + "invalid value for attribute name: #{name.dump} can only include letters, numbers, dashes, and underscores" end if raw_require_paths.empty? then diff --git a/lib/rubygems/text.rb b/lib/rubygems/text.rb index 732f1b99f2..b944b62c27 100644 --- a/lib/rubygems/text.rb +++ b/lib/rubygems/text.rb @@ -7,12 +7,25 @@ require 'rubygems' module Gem::Text ## + # Remove any non-printable characters and make the text suitable for + # printing. + def clean_text(text) + text.gsub(/[\000-\b\v-\f\016-\037\177]/, ".".freeze) + end + + def truncate_text(text, description, max_length = 100_000) + raise ArgumentError, "max_length must be positive" unless max_length > 0 + return text if text.size <= max_length + "Truncating #{description} to #{max_length.to_s.reverse.gsub(/...(?=.)/,'\&,').reverse} characters:\n" + text[0, max_length] + end + + ## # Wraps +text+ to +wrap+ characters and optionally indents by +indent+ # characters def format_text(text, wrap, indent=0) result = [] - work = text.dup + work = clean_text(text) while work.length > wrap do if work =~ /^(.{0,#{wrap}})[ \n]/ then |