Server IP : 104.21.38.3 / Your IP : 162.158.108.43 Web Server : Apache System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /lib/ruby/vendor_ruby/rubygems/ |
Upload File : |
# frozen_string_literal: true ## # The Uri handles rubygems source URIs. # class Gem::Uri def initialize(source_uri) @parsed_uri = parse(source_uri) end def redacted return self unless valid_uri? if token? || oauth_basic? with_redacted_user elsif password? with_redacted_password else self end end def to_s @parsed_uri.to_s end def redact_credentials_from(text) return text unless valid_uri? && password? text.sub(password, 'REDACTED') end def method_missing(method_name, *args, &blk) if @parsed_uri.respond_to?(method_name) @parsed_uri.send(method_name, *args, &blk) else super end end def respond_to_missing?(method_name, include_private = false) @parsed_uri.respond_to?(method_name, include_private) || super end protected # Add a protected reader for the cloned instance to access the original object's parsed uri attr_reader :parsed_uri private ## # Parses the #uri, raising if it's invalid def parse!(uri) require "uri" raise URI::InvalidURIError unless uri # Always escape URI's to deal with potential spaces and such # It should also be considered that source_uri may already be # a valid URI with escaped characters. e.g. "{DESede}" is encoded # as "%7BDESede%7D". If this is escaped again the percentage # symbols will be escaped. begin URI.parse(uri) rescue URI::InvalidURIError URI.parse(URI::DEFAULT_PARSER.escape(uri)) end end ## # Parses the #uri, returning the original uri if it's invalid def parse(uri) return uri unless uri.is_a?(String) parse!(uri) rescue URI::InvalidURIError uri end def with_redacted_user clone.tap {|uri| uri.user = 'REDACTED' } end def with_redacted_password clone.tap {|uri| uri.password = 'REDACTED' } end def valid_uri? !@parsed_uri.is_a?(String) end def password? !!password end def oauth_basic? password == 'x-oauth-basic' end def token? !user.nil? && password.nil? end def initialize_copy(original) @parsed_uri = original.parsed_uri.clone end end