diff options
-rw-r--r-- | morphlib/remoteartifactcache.py | 6 | ||||
-rw-r--r-- | morphlib/remoteartifactcache_tests.py | 7 |
2 files changed, 10 insertions, 3 deletions
diff --git a/morphlib/remoteartifactcache.py b/morphlib/remoteartifactcache.py index 17f547f2..9f6bf69e 100644 --- a/morphlib/remoteartifactcache.py +++ b/morphlib/remoteartifactcache.py @@ -1,4 +1,4 @@ -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -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..e7f45f58 100644 --- a/morphlib/remoteartifactcache_tests.py +++ b/morphlib/remoteartifactcache_tests.py @@ -1,4 +1,4 @@ -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -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) |