From ee8a76f32bee3d357d9965ae7deac50c36268987 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Thu, 13 Aug 2015 16:54:27 -0400 Subject: [PATCH] Use smart_str instead of .encode on passwords We originally tried to prune these .encode() calls out of the tree in favor of smart_str but we must have missed this one. This allows migration 0066 to work if utf-8 characters are used in the password --- awx/main/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/main/utils.py b/awx/main/utils.py index 1d07e5f4f7..a800414755 100644 --- a/awx/main/utils.py +++ b/awx/main/utils.py @@ -147,7 +147,7 @@ def encrypt_field(instance, field_name, ask=False): value = getattr(instance, field_name) if not value or value.startswith('$encrypted$') or (ask and value == 'ASK'): return value - value = value.encode('utf-8') + value = smart_str(value) key = get_encryption_key(instance, field_name) cipher = AES.new(key, AES.MODE_ECB) while len(value) % cipher.block_size != 0: