From 69cc414c1debb92aa985fe9ecdca1facb7c36588 Mon Sep 17 00:00:00 2001 From: Joe Rafaniello Date: Tue, 16 Feb 2021 12:08:26 -0500 Subject: [PATCH] Use URI::DEFAULT_PARSER escape/unescape to avoid ruby 2.7 warnings 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: https://github.com/ManageIQ/manageiq/pull/21036 Related: https://github.com/ManageIQ/manageiq/issues/19678 (transferred from ManageIQ/manageiq-gems-pending@3bddaa4ce2c44c46c953a2d573a7327a1cb4d584) --- .../smartstate/mount/miq_generic_mount_session.rb | 8 ++++---- lib/manageiq/smartstate/mount/miq_glusterfs_session.rb | 2 +- lib/manageiq/smartstate/mount/miq_nfs_session.rb | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/manageiq/smartstate/mount/miq_generic_mount_session.rb b/lib/manageiq/smartstate/mount/miq_generic_mount_session.rb index 56f400f..c8a1c08 100644 --- a/lib/manageiq/smartstate/mount/miq_generic_mount_session.rb +++ b/lib/manageiq/smartstate/mount/miq_generic_mount_session.rb @@ -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 @@ -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 @@ -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', ' ') diff --git a/lib/manageiq/smartstate/mount/miq_glusterfs_session.rb b/lib/manageiq/smartstate/mount/miq_glusterfs_session.rb index 222f751..ebfb0c9 100644 --- a/lib/manageiq/smartstate/mount/miq_glusterfs_session.rb +++ b/lib/manageiq/smartstate/mount/miq_glusterfs_session.rb @@ -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 diff --git a/lib/manageiq/smartstate/mount/miq_nfs_session.rb b/lib/manageiq/smartstate/mount/miq_nfs_session.rb index 53857d2..ce604b9 100644 --- a/lib/manageiq/smartstate/mount/miq_nfs_session.rb +++ b/lib/manageiq/smartstate/mount/miq_nfs_session.rb @@ -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