summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/rubygems/errors.rb3
-rw-r--r--test/rubygems/test_gem_source_fetch_problem.rb10
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/rubygems/errors.rb b/lib/rubygems/errors.rb
index abee20651e..86f0d1da14 100644
--- a/lib/rubygems/errors.rb
+++ b/lib/rubygems/errors.rb
@@ -171,8 +171,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}"
+ "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 0b1472c0c6..816407781d 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
refute_match sf.wordy, 'secret'
end
+
+ def test_source_password_no_redacted
+ source = Gem::Source.new 'https://username:[email protected]'
+ error = RuntimeError.new 'test'
+
+ sf = Gem::SourceFetchProblem.new source, error
+ sf.wordy
+
+ assert_match 'secret', source.uri.to_s
+ end
end