Replace URI.escape() with ERB::Util.url_encode()

URI.escape() method has been removed in ruby 3 and
the newly added Puppet::Util.rfc2396_escape()[1]
has not been released yet.

[1] 41dcae71c7

Closes-Bug: #1928685
Change-Id: I001d579a1b126fc8254f071ddbecda5cc6de7231
(cherry picked from commit 0699227b3c)
This commit is contained in:
ramishra 2021-05-20 09:02:15 +05:30 committed by Alex Schultz
parent 3a6113b3b5
commit 710bcb855c
2 changed files with 6 additions and 6 deletions

View File

@ -1,6 +1,6 @@
Puppet::Functions.create_function(:os_database_connection) do
def os_database_connection(*args)
require 'uri'
require 'erb'
if (args.size != 1) then
raise(Puppet::ParseError, "os_database_connection(): Wrong number of arguments " +
@ -44,9 +44,9 @@ Puppet::Functions.create_function(:os_database_connection) do
end
if v.include?('username') and (v['username'] != :undef) and (v['username'].to_s != '')
parts[:userinfo] = URI.escape(v['username'])
parts[:userinfo] = ERB::Util.url_encode(v['username'])
if v.include?('password') and (v['password'] != :undef) and (v['password'].to_s != '')
parts[:userinfo] += ":#{URI.escape(v['password'])}"
parts[:userinfo] += ":#{ERB::Util.url_encode(v['password'])}"
end
end

View File

@ -80,7 +80,7 @@ Puppet::Functions.create_function(:os_transport_url) do
end
def os_transport_url(*args)
require 'uri'
require 'erb'
unless args.size == 1
raise(ArgumentError, 'os_transport_url(): Wrong number of arguments')
@ -130,9 +130,9 @@ Puppet::Functions.create_function(:os_transport_url) do
parts[:transport] = v['transport']
if v.include?('username') and (v['username'] != :undef) and (v['username'].to_s != '')
parts[:userinfo] = URI.escape(v['username'])
parts[:userinfo] = ERB::Util.url_encode(v['username'])
if v.include?('password') and (v['password'] != :undef) and (v['password'].to_s != '')
parts[:userinfo] += ":#{URI.escape(v['password'])}"
parts[:userinfo] += ":#{ERB::Util.url_encode(v['password'])}"
end
end