From bcf2119a7cb45b822708971e8d8117ea72209769 Mon Sep 17 00:00:00 2001 From: frikky Date: Thu, 21 Apr 2022 19:00:50 +0200 Subject: [PATCH] Fixed an issue with ast literal eval parsing 7e7 as a mathematical operation instead of pure string --- backend/app_sdk/app_base.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/app_sdk/app_base.py b/backend/app_sdk/app_base.py index 69dc1687..dc268870 100644 --- a/backend/app_sdk/app_base.py +++ b/backend/app_sdk/app_base.py @@ -3089,11 +3089,12 @@ class AppBase: for key, value in params.items(): try: if isinstance(value, str) and ((value.startswith("{") and value.endswith("}")) or (value.startswith("[") and value.endswith("]"))): - params[key] = ast.literal_eval(value) + params[key] = json.loads(value) except Exception as e: try: - params[key] = json.loads(value) - except json.decoder.JSONDecodeError as e: + if isinstance(value, str) and ((value.startswith("{") and value.endswith("}")) or (value.startswith("[") and value.endswith("]"))): + params[key] = ast.literal_eval(value) + except Exception as e: self.logger.info(f"[DEBUG] Failed parsing value with ast and json.loads - noncritical. Trying next: {e}") continue except Exception as e: