diff options
-rw-r--r-- | openstack/common/log.py | 7 | ||||
-rw-r--r-- | tests/unit/test_log.py | 4 |
2 files changed, 10 insertions, 1 deletions
diff --git a/openstack/common/log.py b/openstack/common/log.py index a0e17ff0..c2fc4ac7 100644 --- a/openstack/common/log.py +++ b/openstack/common/log.py @@ -264,7 +264,12 @@ def mask_password(message, secret="***"): >>> mask_password("u'original_password' : u'aaaaa'") "u'original_password' : u'***'" """ - message = six.text_type(message) + try: + message = six.text_type(message) + except UnicodeDecodeError: + # NOTE(jecarey): Temporary fix to handle cases where message is a + # byte string. A better solution will be provided in Kilo. + pass # NOTE(ldbragst): Check to see if anything in message contains any key # specified in _SANITIZE_KEYS, if not then just return the message since diff --git a/tests/unit/test_log.py b/tests/unit/test_log.py index 57f9887b..846c6d57 100644 --- a/tests/unit/test_log.py +++ b/tests/unit/test_log.py @@ -864,3 +864,7 @@ class MaskPasswordTestCase(test.BaseTestCase): payload = six.text_type(payload) expected = """{'adminPass':'***'}""" self.assertEqual(expected, log.mask_password(payload)) + + payload = 'test = "original_password" : "my\xe9\x80\x80pass"' + expected = 'test = "original_password" : "***"' + self.assertEqual(expected, log.mask_password(payload)) |