Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(MODULES-11126) Replacing URI.escape with URI::DEFAULT_PARSER #1195

Merged
merged 1 commit into from
Sep 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/puppet/parser/functions/uriescape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ module Puppet::Parser::Functions

result = if value.is_a?(Array)
# Numbers in Puppet are often string-encoded which is troublesome ...
value.map { |i| i.is_a?(String) ? URI.escape(i) : i }
value.map { |i| i.is_a?(String) ? URI::DEFAULT_PARSER.escape(i) : i }
else
URI.escape(value)
URI::DEFAULT_PARSER.escape(value)
end

return result
Expand Down
8 changes: 4 additions & 4 deletions spec/functions/uriescape_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
end

describe 'handling normal strings' do
it 'calls ruby\'s URI.escape function' do
expect(URI).to receive(:escape).with('uri_string').and_return('escaped_uri_string').once
it 'calls ruby\'s URI::DEFAULT_PARSER.escape function' do
expect(URI::DEFAULT_PARSER).to receive(:escape).with('uri_string').and_return('escaped_uri_string').once
is_expected.to run.with_params('uri_string').and_return('escaped_uri_string')
end
end

describe 'handling classes derived from String' do
it 'calls ruby\'s URI.escape function' do
it 'calls ruby\'s URI::DEFAULT_PARSER.escape function' do
uri_string = AlsoString.new('uri_string')
expect(URI).to receive(:escape).with(uri_string).and_return('escaped_uri_string').once
expect(URI::DEFAULT_PARSER).to receive(:escape).with(uri_string).and_return('escaped_uri_string').once
is_expected.to run.with_params(uri_string).and_return('escaped_uri_string')
end
end
Expand Down