diff --git a/protocols/ircs2s_common.py b/protocols/ircs2s_common.py index 480c8e2..1707e18 100644 --- a/protocols/ircs2s_common.py +++ b/protocols/ircs2s_common.py @@ -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 {} diff --git a/test/test_irc_parsers.py b/test/test_irc_parsers.py index 04d71fd..530560a 100644 --- a/test/test_irc_parsers.py +++ b/test/test_irc_parsers.py @@ -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)