mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
[fix] Make funcparser correctly preserve one escape character if using e.g. \\. Resolve #3692.
This commit is contained in:
parent
6567f26615
commit
c2e71f4acb
4 changed files with 11 additions and 7 deletions
|
|
@ -14,6 +14,8 @@
|
||||||
finds `big sword` even if another type of sword is around (InspectorCaracal)
|
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
|
- [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)
|
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
|
- [Docs]: Fixes from InspectorCaracal, Griatch
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@ class CmdNick(COMMAND_DEFAULT_CLASS):
|
||||||
nick build $1 $2 = create/drop $1;$2
|
nick build $1 $2 = create/drop $1;$2
|
||||||
nick tell $1 $2=page $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
|
nick tm\\\\=$1=page tallman=$1
|
||||||
|
|
||||||
A 'nick' is a personal string replacement. Use $1, $2, ... to catch arguments.
|
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
|
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
|
? - matches 0 or 1 single characters
|
||||||
[abcd] - matches these chars in any order
|
[abcd] - matches these chars in any order
|
||||||
[!abcd] - matches everything not among these chars
|
[!abcd] - matches everything not among these chars
|
||||||
\= - escape literal '=' you want in your <string>
|
\\\\= - escape literal '=' you want in your <string>
|
||||||
|
|
||||||
Note that no objects are actually renamed or changed by this command - your nicks
|
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
|
are only available to you. If you want to permanently add keywords to an object
|
||||||
|
|
|
||||||
|
|
@ -334,7 +334,7 @@ class FuncParser:
|
||||||
infuncstr = "" # string parts inside the current level of $funcdef (including $)
|
infuncstr = "" # string parts inside the current level of $funcdef (including $)
|
||||||
literal_infuncstr = False
|
literal_infuncstr = False
|
||||||
|
|
||||||
for char in string:
|
for ichar, char in enumerate(string):
|
||||||
if escaped:
|
if escaped:
|
||||||
# always store escaped characters verbatim
|
# always store escaped characters verbatim
|
||||||
if curr_func:
|
if curr_func:
|
||||||
|
|
@ -345,8 +345,9 @@ class FuncParser:
|
||||||
escaped = False
|
escaped = False
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if char == escape_char:
|
if char == escape_char and string[ichar + 1 : ichar + 2] != escape_char:
|
||||||
# don't store the escape-char itself
|
# don't store the escape-char itself, but keep one escape-char,
|
||||||
|
# if it's followed by another escape-char
|
||||||
escaped = True
|
escaped = True
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -231,8 +231,9 @@ class TestFuncParser(TestCase):
|
||||||
("Test literal3 $typ($lit(1)aaa)", "Test literal3 <class 'str'>"),
|
("Test literal3 $typ($lit(1)aaa)", "Test literal3 <class 'str'>"),
|
||||||
("Test literal4 $typ(aaa$lit(1))", "Test literal4 <class 'str'>"),
|
("Test literal4 $typ(aaa$lit(1))", "Test literal4 <class 'str'>"),
|
||||||
("Test spider's thread", "Test spider's thread"),
|
("Test spider's thread", "Test spider's thread"),
|
||||||
("Test invalid syntax $a=$b", "Test invalid syntax $a=$b"),
|
("Test escape syntax $a=$b", "Test escape syntax $a=$b"),
|
||||||
(r"Test invalid syntax $a\= b", "Test invalid 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):
|
def test_parse(self, string, expected):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue