3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-24 03:29:28 +01:00

parse_message_args: remove extraneous \'s that aren't escaping characters

This commit is contained in:
James Lu 2019-09-10 18:30:43 -07:00
parent aba198dbd6
commit 943168df53
2 changed files with 12 additions and 7 deletions

View File

@ -150,14 +150,18 @@ class IRCCommonProtocol(IRCNetwork):
if data[0].startswith('@'):
tagdata = data[0].lstrip('@').split(';')
for idx, tag in enumerate(tagdata):
tag = tag.replace(r'\s', ' ')
tag = tag.replace(r'\\', '\\')
tag = tag.replace(r'\r', '\r')
tag = tag.replace(r'\n', '\n')
tag = tag.replace(r'\:', ';')
tag = tag.replace('\\s', ' ')
tag = tag.replace('\\r', '\r')
tag = tag.replace('\\n', '\n')
tag = tag.replace('\\:', ';')
# We want to drop lone \'s but keep \\ as \ ...
tag = tag.replace('\\\\', '\x00')
tag = tag.replace('\\', '')
tag = tag.replace('\x00', '\\')
tagdata[idx] = tag
results = cls.parse_isupport(tagdata, fallback=None)
results = cls.parse_isupport(tagdata, fallback='')
return results
return {}

View File

@ -46,7 +46,8 @@ class MessageParserTest(unittest.TestCase):
# method that relies on command handlers being present. So we can't reasonably test
# them here (plus handle_events() outputs params as a command-specific dict instead of)
# lists)
self.assertEqual(atoms['tags'], IRCCommonProtocol.parse_message_tags(inp.split(" ")))
self.assertEqual(atoms['tags'], IRCCommonProtocol.parse_message_tags(inp.split(" ")),
"Parse test failed for message tags: %r" % inp)
_, inp = inp.split(" ", 1)
if has_source:
parts = IRCCommonProtocol.parse_prefixed_args(inp)