Added escape sequence to string_function as a workaround for the problem of missing {} for unknown reason

This commit is contained in:
NattoMaki
2023-11-26 18:45:37 +09:00
parent 9768d1c03c
commit 17f67bb3f0
+4
View File
@@ -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)