Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Protecting `QueryMapper.values_to_query` from modified behaviour of `…

…Addressable::URI.encode_component` which now modifies passed string object in version 2.3.3 of Addressable.
  • Loading branch information...
commit 3965f1ef31fcaddf4ef394c8f0bd05ce5656fcd2 1 parent 2c70051
@bblimke authored
Showing with 4 additions and 3 deletions.
  1. +4 −3 lib/webmock/util/query_mapper.rb
View
7 lib/webmock/util/query_mapper.rb
@@ -114,6 +114,7 @@ def self.query_to_values(query, options={})
#
# @param [Hash, #to_hash, Array] new_query_values The new query values.
def self.values_to_query(new_query_values)
+
if new_query_values == nil
return nil
end
@@ -146,7 +147,7 @@ def self.values_to_query(new_query_values)
if value.is_a?(Hash)
value = value.map do |key, val|
[
- Addressable::URI.encode_component(key, Addressable::URI::CharacterClasses::UNRESERVED),
+ Addressable::URI.encode_component(key.dup, Addressable::URI::CharacterClasses::UNRESERVED),
val
]
end
@@ -168,7 +169,7 @@ def self.values_to_query(new_query_values)
return parent
else
encoded_value = Addressable::URI.encode_component(
- value, Addressable::URI::CharacterClasses::UNRESERVED
+ value.dup, Addressable::URI::CharacterClasses::UNRESERVED
)
return "#{parent}=#{encoded_value}"
end
@@ -178,7 +179,7 @@ def self.values_to_query(new_query_values)
buffer = ""
new_query_values.each do |parent, value|
encoded_parent = Addressable::URI.encode_component(
- parent, Addressable::URI::CharacterClasses::UNRESERVED
+ parent.dup, Addressable::URI::CharacterClasses::UNRESERVED
)
buffer << "#{to_query.call(encoded_parent, value)}&"
end
Please sign in to comment.
Something went wrong with that request. Please try again.