From 65b28062097e9fb18ab14757d8657ebb5b1268d3 Mon Sep 17 00:00:00 2001 From: Count Infinity Date: Sat, 14 Dec 2024 01:43:01 -0700 Subject: [PATCH] Fixing funcparser issues --- evennia/utils/funcparser.py | 4 +++- evennia/utils/tests/test_funcparser.py | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/evennia/utils/funcparser.py b/evennia/utils/funcparser.py index c0de83838a..da7f4b3457 100644 --- a/evennia/utils/funcparser.py +++ b/evennia/utils/funcparser.py @@ -339,6 +339,7 @@ class FuncParser: # always store escaped characters verbatim if curr_func: infuncstr += char + curr_func.rawstr += char else: fullstr += char escaped = False @@ -372,7 +373,8 @@ class FuncParser: curr_func.open_lsquare = open_lsquare curr_func.open_lcurly = open_lcurly # we must strip the remaining funcstr so it's not counted twice - curr_func.rawstr = curr_func.rawstr[: -len(infuncstr)] + if len(infuncstr) > 0: + curr_func.rawstr = curr_func.rawstr[: -len(infuncstr)] current_kwarg = "" infuncstr = "" double_quoted = -1 diff --git a/evennia/utils/tests/test_funcparser.py b/evennia/utils/tests/test_funcparser.py index 7756a95999..10061a32f0 100644 --- a/evennia/utils/tests/test_funcparser.py +++ b/evennia/utils/tests/test_funcparser.py @@ -231,6 +231,8 @@ class TestFuncParser(TestCase): ("Test literal3 $typ($lit(1)aaa)", "Test literal3 "), ("Test literal4 $typ(aaa$lit(1))", "Test literal4 "), ("Test spider's thread", "Test spider's thread"), + ("Test invalid syntax $a=$b", "Test invalid syntax $a=$b"), + (r"Test invalid syntax $a\= b", "Test invalid syntax $a= b"), ] ) def test_parse(self, string, expected):