Skip to content
This repository was archived by the owner on Nov 29, 2023. It is now read-only.

Commit 60cfebc

Browse files
committed
Quote image ids before passing them to glance
If the image id contains a space it needs to be quoted or else it will construct an improper header. Fixes bug 1111948 Change-Id: I4db2e74401b57de9666d40b38151182b2a76cd1b
1 parent ed67c32 commit 60cfebc

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

glanceclient/v1/images.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,16 @@ def _format_image_meta_for_user(meta):
9191
pass
9292
return meta
9393

94-
def get(self, image_id):
94+
def get(self, image):
9595
"""Get the metadata for a specific image.
9696
9797
:param image: image object or id to look up
9898
:rtype: :class:`Image`
9999
"""
100-
resp, body = self.api.raw_request('HEAD', '/v1/images/%s' % image_id)
100+
101+
image_id = base.getid(image)
102+
resp, body = self.api.raw_request('HEAD', '/v1/images/%s'
103+
% urllib.quote(image_id))
101104
meta = self._image_meta_from_headers(dict(resp.getheaders()))
102105
return Image(self, meta)
103106

@@ -109,7 +112,8 @@ def data(self, image, do_checksum=True):
109112
:rtype: iterable containing image data
110113
"""
111114
image_id = base.getid(image)
112-
resp, body = self.api.raw_request('GET', '/v1/images/%s' % image_id)
115+
resp, body = self.api.raw_request('GET', '/v1/images/%s'
116+
% urllib.quote(image_id))
113117
checksum = resp.getheader('x-image-meta-checksum', None)
114118
if do_checksum and checksum is not None:
115119
return utils.integrity_iter(body, checksum)

0 commit comments

Comments
 (0)