Skip to content

Commit

Permalink
Use URI::DEFAULT_PARSER escape/unescape to avoid ruby 2.7 warnings
Browse files Browse the repository at this point in the history
Fixes various warnings of this variety:
app/models/file_depot_ftp.rb:128: warning: URI.escape is obsolete
app/models/mixins/file_depot_mixin.rb:42: warning: URI.escape is obsolete

From: ManageIQ/manageiq#21036

Related: ManageIQ/manageiq#19678


(transferred from ManageIQ/manageiq-gems-pending@3bddaa4)
  • Loading branch information
jrafanie authored and NickLaMuro committed Aug 10, 2021
1 parent 0687a49 commit c6081ed
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions lib/manageiq/smartstate/mount/miq_generic_mount_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def self.new_with_opts(opts)

def self.uri_scheme_to_class(uri)
require 'uri'
scheme, userinfo, host, port, registry, share, opaque, query, fragment = URI.split(URI.encode(uri))
scheme, userinfo, host, port, registry, share, opaque, query, fragment = URI.split(URI::DEFAULT_PARSER.escape(uri))
case scheme
when 'smb'
MiqSmbSession
Expand Down Expand Up @@ -327,8 +327,8 @@ def log_uri_still_configured?(log_uri)
# Only remove the log file if the current depot @settings are based on the same base URI as the log_uri to be removed
return false if log_uri.nil? || @settings[:uri].nil?

scheme, userinfo, host, port, registry, share, opaque, query, fragment = URI.split(URI.encode(@settings[:uri]))
scheme_log, userinfo_log, host_log, port_log, registry_log, share_log, opaque_log, query_log, fragment_log = URI.split(URI.encode(log_uri))
scheme, userinfo, host, port, registry, share, opaque, query, fragment = URI.split(URI::DEFAULT_PARSER.escape(@settings[:uri]))
scheme_log, userinfo_log, host_log, port_log, registry_log, share_log, opaque_log, query_log, fragment_log = URI.split(URI::DEFAULT_PARSER.escape(log_uri))

return false if scheme != scheme_log
return false if host != host_log
Expand Down Expand Up @@ -457,7 +457,7 @@ def mount_root
def relative_to_mount(uri)
log_header = "MIQ(#{self.class.name}-relative_to_mount)"
logger.info("#{log_header} mount point [#{@mount_path}], uri: [#{uri}]...")
scheme, userinfo, host, port, registry, path, opaque, query, fragment = URI.split(URI.encode(uri))
scheme, userinfo, host, port, registry, path, opaque, query, fragment = URI.split(URI::DEFAULT_PARSER.escape(uri))

# Replace any encoded spaces back into spaces since the mount commands accepts quoted spaces
path.gsub!('%20', ' ')
Expand Down
2 changes: 1 addition & 1 deletion lib/manageiq/smartstate/mount/miq_glusterfs_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def initialize(log_settings)

def connect
_scheme, _userinfo, @host, _port, _registry, @mount_path, _opaque, _query, _fragment =
URI.split(URI.encode(@settings[:uri]))
URI.split(URI::DEFAULT_PARSER.escape(@settings[:uri]))
super
end

Expand Down
2 changes: 1 addition & 1 deletion lib/manageiq/smartstate/mount/miq_nfs_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def initialize(log_settings)
end

def connect
scheme, userinfo, @host, port, registry, @mount_path, opaque, query, fragment = URI.split(URI.encode(@settings[:uri]))
scheme, userinfo, @host, port, registry, @mount_path, opaque, query, fragment = URI.split(URI::DEFAULT_PARSER.escape(@settings[:uri]))
super
end

Expand Down

0 comments on commit c6081ed

Please sign in to comment.