From 17f67bb3f0dba950198e478b1cae3bf0876ba45e Mon Sep 17 00:00:00 2001 From: NattoMaki Date: Sun, 26 Nov 2023 18:45:37 +0900 Subject: [PATCH] Added escape sequence to string_function as a workaround for the problem of missing {} for unknown reason --- negi/string_function.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/negi/string_function.py b/negi/string_function.py index 963d70e..471e121 100644 --- a/negi/string_function.py +++ b/negi/string_function.py @@ -49,9 +49,13 @@ class StringFunction: CATEGORY = "utils" def doit(self, python_code, a, b, c): + # print("code = \"%s\"" % python_code) if python_code.find("import") != -1: raise ValueError("\"import\" cannot be included in python_code for security reasons") + # Workaround for a strange behavior of STRING + python_code = python_code.replace("\\{", "{") + python_code = python_code.replace("\\}", "}") code = (_sandbox_template0 + " " + "\n ".join((python_code + "\n").split("\n")) + "\n" + _sandbox_template1)