Skip to content

Commit

Permalink
Correctly encode URI segments
Browse files Browse the repository at this point in the history
CGI.escape encodes spaces as `+`s, which is not
correct for paths.

Fixes #28.
  • Loading branch information
michaelklishin committed Feb 1, 2017
1 parent 7122c82 commit b7e645d
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/rabbitmq/http/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
require "multi_json"
require "uri"

# for URI encoding
require "cgi"

module RabbitMQ
module HTTP
class Client
Expand Down Expand Up @@ -419,7 +416,8 @@ def initialize_connection(endpoint, options = {})
end

def uri_encode(s)
CGI.escape(s)
# correctly escapes spaces, unlike CGI.escape, see ruby-amqp/rabbitmq_http_api_client#28
URI.escape(s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
end

def decode_resource(response)
Expand Down

0 comments on commit b7e645d

Please # to comment.