diff --git a/swift/common/middleware/tempurl.py b/swift/common/middleware/tempurl.py index a97bd95e31..c2655883f8 100644 --- a/swift/common/middleware/tempurl.py +++ b/swift/common/middleware/tempurl.py @@ -97,9 +97,8 @@ from urllib import urlencode from urlparse import parse_qs from swift.proxy.controllers.base import get_account_info -from swift.common.swob import HeaderKeyDict -from swift.common.utils import split_path -from swift.common.swob import HTTPUnauthorized +from swift.common.swob import HeaderKeyDict, HTTPUnauthorized +from swift.common.utils import split_path, get_valid_utf8_str #: Default headers to remove from incoming requests. Simply a whitespace @@ -136,7 +135,7 @@ def get_tempurl_keys_from_metadata(meta): meta = get_account_info(...)['meta'] keys = get_tempurl_keys_from_metadata(meta) """ - return [value for key, value in meta.iteritems() + return [get_valid_utf8_str(value) for key, value in meta.iteritems() if key.lower() in ('temp-url-key', 'temp-url-key-2')] diff --git a/test/unit/common/middleware/test_tempurl.py b/test/unit/common/middleware/test_tempurl.py index 86d5b8934f..580f617dc0 100644 --- a/test/unit/common/middleware/test_tempurl.py +++ b/test/unit/common/middleware/test_tempurl.py @@ -803,6 +803,12 @@ class TestTempURL(unittest.TestCase): self.assertTrue('test-header-yes' not in hdrs) self.assertTrue('test-header-yes-this' in hdrs) + def test_unicode_metadata_value(self): + meta = {"temp-url-key": "test", "temp-url-key-2": u"test2"} + results = tempurl.get_tempurl_keys_from_metadata(meta) + for str_value in results: + self.assertTrue(isinstance(str_value, str)) + if __name__ == '__main__': unittest.main()