Skip to content

Commit 28ad783

Browse files
committed
Fix escaping issue
1 parent e276162 commit 28ad783

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/azure_blob/client.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ def blob_exist?(key, options = {})
194194
#
195195
# Returns a hash of the blob's tags.
196196
def get_blob_tags(key)
197-
uri = generate_uri("#{container}/#{key}?comp=tags")
197+
uri = generate_uri("#{container}/#{key}")
198+
uri.query = URI.encode_www_form(comp: "tags")
198199
response = Http.new(uri, signer:).get
199200

200201
Tags.from_response(response).to_h
@@ -246,7 +247,8 @@ def delete_container(options = {})
246247
#
247248
# Example: +generate_uri("#{container}/#{key}")+
248249
def generate_uri(path)
249-
URI.parse(URI::RFC2396_PARSER.escape(File.join(host, path)))
250+
encoded = path.split("/").map { |segment| CGI.escape(segment) }.join("/")
251+
URI.parse([host.chomp("/"), encoded].join("/"))
250252
end
251253

252254
# Returns an SAS signed URI

test/client/test_client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def setup
2323
host: @host,
2424
)
2525
@uid = SecureRandom.uuid
26-
@key = "test-client-#{name}-#{@uid}"
26+
@key = "test-client-?-#{name}-#{@uid}" # ? in key to test proper escaping
2727
@content = "Some random content #{Random.rand(200)}"
2828
end
2929

0 commit comments

Comments
 (0)