ruby-changes:68107
From: huangduirong <ko1@a...>
Date: Fri, 24 Sep 2021 10:59:31 +0900 (JST)
Subject: [ruby-changes:68107] b1ab1ee046 (master): [rubygems/rubygems] Fix error message building changing password of source
https://git.ruby-lang.org/ruby.git/commit/?id=b1ab1ee046 From b1ab1ee046816b021a3cbd0a08bfce0e459beb4b Mon Sep 17 00:00:00 2001 From: huangduirong <huangduirong@h...> Date: Thu, 9 Sep 2021 15:24:41 +0800 Subject: [rubygems/rubygems] Fix error message building changing password of source Do not change the password of the input parameter source during anonymization, by using the proper helper instead of changing the original uri directly. https://github.com/rubygems/rubygems/commit/eaa2dd8a97 --- lib/rubygems/errors.rb | 3 +-- test/rubygems/test_gem_source_fetch_problem.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/rubygems/errors.rb b/lib/rubygems/errors.rb index abee206..86f0d1d 100644 --- a/lib/rubygems/errors.rb +++ b/lib/rubygems/errors.rb @@ -171,8 +171,7 @@ module Gem https://github.com/ruby/ruby/blob/trunk/lib/rubygems/errors.rb#L171 # 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}" + "Unable to download data from #{Gem::Uri.new(@source.uri).redacted} - #{@error.message}" end ## diff --git a/test/rubygems/test_gem_source_fetch_problem.rb b/test/rubygems/test_gem_source_fetch_problem.rb index 0b1472c..8164077 100644 --- a/test/rubygems/test_gem_source_fetch_problem.rb +++ b/test/rubygems/test_gem_source_fetch_problem.rb @@ -23,4 +23,14 @@ class TestGemSourceFetchProblem < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_source_fetch_problem.rb#L23 refute_match sf.wordy, 'secret' end + + def test_source_password_no_redacted + source = Gem::Source.new 'https://username:secret@g...' + error = RuntimeError.new 'test' + + sf = Gem::SourceFetchProblem.new source, error + sf.wordy + + assert_match 'secret', source.uri.to_s + end end -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/