diff --git a/CHANGELOG.md b/CHANGELOG.md index 787abdfcb5..cb85a26030 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ finds `big sword` even if another type of sword is around (InspectorCaracal) - [Fix][pull3690]: In searches, allow special 'here' and 'me' keywords only be valid queries unless current location and/or caller is in valid search candidates respectively (InspectorCaracal) +- [Fix][pull3694]: Funcparser swallowing rest of line after a `\`-escape (count-infinity) +- Fix: Make `\\` properly preserve one backlash in funcparser (Griatch) - [Docs]: Fixes from InspectorCaracal, Griatch diff --git a/evennia/commands/default/general.py b/evennia/commands/default/general.py index 06aae08f75..e1eff225ee 100644 --- a/evennia/commands/default/general.py +++ b/evennia/commands/default/general.py @@ -118,7 +118,7 @@ class CmdNick(COMMAND_DEFAULT_CLASS): nick build $1 $2 = create/drop $1;$2 nick tell $1 $2=page $1=$2 nick tm?$1=page tallman=$1 - nick tm\=$1=page tallman=$1 + nick tm\\\\=$1=page tallman=$1 A 'nick' is a personal string replacement. Use $1, $2, ... to catch arguments. Put the last $-marker without an ending space to catch all remaining text. You @@ -128,7 +128,7 @@ class CmdNick(COMMAND_DEFAULT_CLASS): ? - matches 0 or 1 single characters [abcd] - matches these chars in any order [!abcd] - matches everything not among these chars - \= - escape literal '=' you want in your + \\\\= - escape literal '=' you want in your Note that no objects are actually renamed or changed by this command - your nicks are only available to you. If you want to permanently add keywords to an object diff --git a/evennia/utils/funcparser.py b/evennia/utils/funcparser.py index da7f4b3457..2ed3243004 100644 --- a/evennia/utils/funcparser.py +++ b/evennia/utils/funcparser.py @@ -334,7 +334,7 @@ class FuncParser: infuncstr = "" # string parts inside the current level of $funcdef (including $) literal_infuncstr = False - for char in string: + for ichar, char in enumerate(string): if escaped: # always store escaped characters verbatim if curr_func: @@ -345,8 +345,9 @@ class FuncParser: escaped = False continue - if char == escape_char: - # don't store the escape-char itself + if char == escape_char and string[ichar + 1 : ichar + 2] != escape_char: + # don't store the escape-char itself, but keep one escape-char, + # if it's followed by another escape-char escaped = True continue diff --git a/evennia/utils/tests/test_funcparser.py b/evennia/utils/tests/test_funcparser.py index 10061a32f0..589219163e 100644 --- a/evennia/utils/tests/test_funcparser.py +++ b/evennia/utils/tests/test_funcparser.py @@ -231,8 +231,9 @@ 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"), + ("Test escape syntax $a=$b", "Test escape syntax $a=$b"), + (r"Test escape syntax $a\= b", "Test escape syntax $a= b"), + (r"Test escape syntax $a\\= $b", r"Test escape syntax $a\= $b"), ] ) def test_parse(self, string, expected):