diff --git a/openstackclient/api/object_store_v1.py b/openstackclient/api/object_store_v1.py index b1c78d990a..ab75a78c29 100644 --- a/openstackclient/api/object_store_v1.py +++ b/openstackclient/api/object_store_v1.py @@ -14,6 +14,7 @@ """Object Store v1 API Library""" import io +import logging import os import six @@ -25,6 +26,7 @@ except ImportError: from urlparse import urlparse # noqa from openstackclient.api import api +from openstackclient.common import utils class APIv1(api.BaseAPI): @@ -551,8 +553,14 @@ class APIv1(api.BaseAPI): # property we use: "X-Add-Container-Meta-Book: MobyDick", and the same # logic applies for Object properties + log = logging.getLogger(__name__ + '._set_properties') + headers = {} for k, v in properties.iteritems(): + if not utils.is_ascii(k) or not utils.is_ascii(v): + log.error('Cannot set property %s to non-ascii value', k) + continue + header_name = header_tag % k headers[header_name] = v return headers diff --git a/openstackclient/common/utils.py b/openstackclient/common/utils.py index 51e2a2f9ca..8db4f35bc8 100644 --- a/openstackclient/common/utils.py +++ b/openstackclient/common/utils.py @@ -419,3 +419,11 @@ def build_kwargs_dict(arg_name, value): if value: kwargs[arg_name] = value return kwargs + + +def is_ascii(string): + try: + string.decode('ascii') + return True + except UnicodeDecodeError: + return False