From f92546e1179792512134ee51134db1107b7075e0 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Mon, 4 Nov 2013 14:48:55 +0000 Subject: Fix RemoteArtifactCache to quote filenames in URLs This will allow fetching of gtk+ artifacts. --- morphlib/remoteartifactcache.py | 4 +++- morphlib/remoteartifactcache_tests.py | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/morphlib/remoteartifactcache.py b/morphlib/remoteartifactcache.py index 17f547f2..c2f88773 100644 --- a/morphlib/remoteartifactcache.py +++ b/morphlib/remoteartifactcache.py @@ -16,6 +16,7 @@ import cliapp import logging +import urllib import urllib2 import urlparse @@ -108,7 +109,8 @@ class RemoteArtifactCache(object): if not server_url.endswith('/'): server_url += '/' return urlparse.urljoin( - server_url, '/1.0/artifacts?filename=%s' % filename) + server_url, '/1.0/artifacts?filename=%s' % + urllib.quote(filename)) def __str__(self): # pragma: no cover return self.server_url diff --git a/morphlib/remoteartifactcache_tests.py b/morphlib/remoteartifactcache_tests.py index 431731b9..dbb094a3 100644 --- a/morphlib/remoteartifactcache_tests.py +++ b/morphlib/remoteartifactcache_tests.py @@ -157,3 +157,8 @@ class RemoteArtifactCacheTests(unittest.TestCase): self.runtime_artifact.source, self.runtime_artifact.cache_key, 'non-existent-meta') + + def test_escapes_pluses_in_request_urls(self): + returned_url = self.cache._request_url('gtk+') + correct_url = '%s/1.0/artifacts?filename=gtk%%2B' % self.server_url + self.assertEqual(returned_url, correct_url) -- cgit v1.2.1