From cbdce186338263e8e64cac174a4f5e077629e23f Mon Sep 17 00:00:00 2001 From: Peter Pfeufer Date: Fri, 24 Jun 2022 23:01:16 +0200 Subject: [PATCH] Use regex to determine the SMF version (thanks @colcrunch) --- allianceauth/services/modules/smf/manager.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/allianceauth/services/modules/smf/manager.py b/allianceauth/services/modules/smf/manager.py index b1c5fb7d..3293c8d3 100644 --- a/allianceauth/services/modules/smf/manager.py +++ b/allianceauth/services/modules/smf/manager.py @@ -67,9 +67,12 @@ class SmfManager: cursor = connections['smf'].cursor() cursor.execute(cls.SQL_GET_CURRENT_SMF_VERSION, ['current-version.js']) row = cursor.fetchone() - smf_version_string = row[0] + db_result = row[0] - smf_version = smf_version_string.replace('window.smfVersion = "SMF ', '').replace('";', '') + pattern = re.compile(r"\d+(\.\d+)+") + result = pattern.search(db_result) + + smf_version = result.group(0) return smf_version