lone backslashes at the end of escaped tag values should be removed

This commit is contained in:
jesopo 2020-03-11 23:56:53 +00:00
parent fd9773efcb
commit 3ae207aa05
2 changed files with 6 additions and 0 deletions

View File

@ -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):

View File

@ -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")