Interpret empty server tag values as missing tag values.

As required by https://ircv3.net/specs/extensions/message-tags
This commit is contained in:
Valentin Lorentz 2019-09-08 14:46:56 +02:00
parent 88524beada
commit f143e977d6
2 changed files with 14 additions and 1 deletions

View File

@ -73,7 +73,12 @@ def parse_server_tags(s):
server_tags[tag] = None
else:
(key, value) = tag.split('=', 1)
server_tags[key] = unescape_server_tag_value(value)
value = unescape_server_tag_value(value)
if value == '':
# "Implementations MUST interpret empty tag values (e.g. foo=)
# as equivalent to missing tag values (e.g. foo)."
value = None
server_tags[key] = value
return server_tags
def format_server_tags(server_tags):
parts = []

View File

@ -147,6 +147,14 @@ class IrcMsgTestCase(SupyTestCase):
self.assertEqual(m.args, ('me', 'Hello'))
self.assertEqual(str(m), s + '\n')
s = '@foo=;bar=baz;qux= ' \
':nick!ident@host.com PRIVMSG me :Hello'
m = ircmsgs.IrcMsg(s)
self.assertEqual(m.server_tags, {
'foo': None,
'bar': 'baz',
'qux': None})
def testTime(self):
before = time.time()
msg = ircmsgs.IrcMsg('PRIVMSG #foo :foo')