summaryrefslogtreecommitdiff
path: root/lib/rubygems
diff options
context:
space:
mode:
authorDaniel Niknam <mhmd.niknam@gmail.com>2021-08-22 19:55:40 +1000
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2021-08-31 19:06:14 +0900
commita508693f06aefe30d2d83c9617541722ba6c8d66 (patch)
tree069944abf917f9c8e1187ab17ea83235efc13485 /lib/rubygems
parentfafd9d280a4ce57c2868a866ae06ba006671bf5a (diff)
[rubygems/rubygems] Remove defensive guards
https://github.com/rubygems/rubygems/commit/dba130cd80
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4789
Diffstat (limited to 'lib/rubygems')
-rw-r--r--lib/rubygems/printable_uri.rb19
1 files changed, 4 insertions, 15 deletions
diff --git a/lib/rubygems/printable_uri.rb b/lib/rubygems/printable_uri.rb
index 53d9fb7685..0837c42b50 100644
--- a/lib/rubygems/printable_uri.rb
+++ b/lib/rubygems/printable_uri.rb
@@ -16,7 +16,7 @@ class Gem::PrintableUri
def parse_uri
@original_uri = Gem::UriParser.parse_uri(@original_uri)
@uri = @original_uri.clone
- redact_credential
+ redact_credential if valid_uri?
self
end
@@ -30,8 +30,6 @@ class Gem::PrintableUri
end
def original_password
- return unless valid_uri?
-
@original_uri.password
end
@@ -42,40 +40,31 @@ class Gem::PrintableUri
private
def redact_credential
- return unless redactable_credential?
-
if token?
@uri.user = 'REDACTED'
+ @credential_redacted = true
elsif oauth_basic?
@uri.user = 'REDACTED'
+ @credential_redacted = true
elsif password?
@uri.password = 'REDACTED'
+ @credential_redacted = true
end
-
- @credential_redacted = true
end
def redactable_credential?
- return false unless valid_uri?
-
password? || oauth_basic? || token?
end
def password?
- return false unless valid_uri?
-
!!@uri.password
end
def oauth_basic?
- return false unless valid_uri?
-
@uri.password == 'x-oauth-basic'
end
def token?
- return false unless valid_uri?
-
!@uri.user.nil? && @uri.password.nil?
end
end