From 377f1454e2fe2f8328f420ee527f4ea6399310e5 Mon Sep 17 00:00:00 2001 From: Eric Fried Date: Tue, 10 Apr 2018 12:24:40 -0500 Subject: [PATCH] Make ResourceClass.normalize_name handle sharp S MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes ResourceClass.normalize_name to produce the same result in py2 and py3 even when sharp S ('ß') is part of the input. We do this by waiting until after replacing non-alphanumerics to upcase. Change-Id: I431fa29d36d0d633374973fc25168344042d6c1a Closes-Bug: #1762789 --- nova/rc_fields.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nova/rc_fields.py b/nova/rc_fields.py index 8481089a7..add6c76a6 100644 --- a/nova/rc_fields.py +++ b/nova/rc_fields.py @@ -58,11 +58,11 @@ class ResourceClass(fields.StringField): def normalize_name(cls, rc_name): if rc_name is None: return None - norm_name = rc_name.upper() - cust_prefix = cls.CUSTOM_NAMESPACE - norm_name = cust_prefix + norm_name - # Replace some punctuation characters with underscores - norm_name = re.sub('[^0-9A-Z]+', '_', norm_name) + # Replace non-alphanumeric characters with underscores + norm_name = re.sub('[^0-9A-Za-z]+', '_', rc_name) + # Bug #1762789: Do .upper after replacing non alphanumerics. + norm_name = norm_name.upper() + norm_name = cls.CUSTOM_NAMESPACE + norm_name return norm_name