mirror of https://github.com/jesopo/irctokens
lone backslashes at the end of escaped tag values should be removed
This commit is contained in:
parent
fd9773efcb
commit
3ae207aa05
|
@ -4,6 +4,8 @@ TAG_UNESCAPED = ["\\", " ", ";", "\r", "\n"]
|
|||
TAG_ESCAPED = ["\\\\", "\\s", "\\:", "\\r", "\\n"]
|
||||
|
||||
def _unescape_tag(value: str):
|
||||
if value.endswith("\\") and not value.endswith("\\\\"):
|
||||
value = value[:-1]
|
||||
parts = value.split("\\\\")
|
||||
for i, piece in enumerate(TAG_ESCAPED):
|
||||
for j, part in enumerate(parts):
|
||||
|
|
|
@ -22,6 +22,10 @@ class TokenTestTags(unittest.TestCase):
|
|||
line = irctokens.tokenise(r"@id=1\\\s\\s PRIVMSG #channel")
|
||||
self.assertEqual(line.tags["id"], "1\\ \\s")
|
||||
|
||||
def test_lone_end_slash(self):
|
||||
line = irctokens.tokenise("@id=1\\ PRIVMSG #channel")
|
||||
self.assertEqual(line.tags["id"], "1")
|
||||
|
||||
class TokenTestSource(unittest.TestCase):
|
||||
def test_without_tags(self):
|
||||
line = irctokens.tokenise(":nick!user@host PRIVMSG #channel")
|
||||
|
|
Loading…
Reference in New Issue