1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[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
This commit is contained in:
huangduirong 2021-09-09 15:24:41 +08:00 committed by Hiroshi SHIBATA
parent 63297c2ca4
commit b1ab1ee046
2 changed files with 11 additions and 2 deletions

View file

@ -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
##

View file

@ -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:secret@gemsource.com'
error = RuntimeError.new 'test'
sf = Gem::SourceFetchProblem.new source, error
sf.wordy
assert_match 'secret', source.uri.to_s
end
end