mirror of
https://github.com/progval/irctest.git
synced 2025-04-08 00:09:46 +00:00
Merge pull request #46 from slingamn/inputtoolong.1
allow ERR_INPUTTOOLONG if a PRIVMSG cannot be relayed
This commit is contained in:
@ -108,6 +108,7 @@ class MessageTagsTestCase(cases.BaseServerTestCase, cases.OptionalityHelper):
|
|||||||
self.assertEqual(alice_msg.tags["msgid"], bob_msg.tags["msgid"])
|
self.assertEqual(alice_msg.tags["msgid"], bob_msg.tags["msgid"])
|
||||||
|
|
||||||
@cases.mark_capabilities("message-tags")
|
@cases.mark_capabilities("message-tags")
|
||||||
|
@cases.mark_specifications("ircdocs")
|
||||||
def testLengthLimits(self):
|
def testLengthLimits(self):
|
||||||
self.connectClient(
|
self.connectClient(
|
||||||
"alice",
|
"alice",
|
||||||
@ -154,25 +155,32 @@ class MessageTagsTestCase(cases.BaseServerTestCase, cases.OptionalityHelper):
|
|||||||
self.assertEqual(len(max_privmsg), 4096 + (512 - 2))
|
self.assertEqual(len(max_privmsg), 4096 + (512 - 2))
|
||||||
self.sendLine("alice", max_privmsg)
|
self.sendLine("alice", max_privmsg)
|
||||||
echo = self.getMessage("alice")
|
echo = self.getMessage("alice")
|
||||||
relay = self.getMessage("bob")
|
# the server may still reject this message on the grounds that the final
|
||||||
self.assertMessageMatch(
|
# parameter is too long to be relayed without truncation, once alice's
|
||||||
echo,
|
# NUH is included. however, if the message was accepted, the tags MUST
|
||||||
command="PRIVMSG",
|
# be relayed intact, because they are unquestionably valid. See the
|
||||||
params=["#test", StrRe("b{400,496}")],
|
# original context of ERR_INPUTTOOLONG:
|
||||||
tags={"+baz": "a" * 4081, "msgid": StrRe(".+"), **ANYDICT},
|
# https://defs.ircdocs.horse/defs/numerics.html#err-inputtoolong-417
|
||||||
)
|
if echo.command != ERR_INPUTTOOLONG:
|
||||||
self.assertMessageMatch(
|
relay = self.getMessage("bob")
|
||||||
relay,
|
self.assertMessageMatch(
|
||||||
command="PRIVMSG",
|
echo,
|
||||||
params=["#test", StrRe("b{400,496}")],
|
command="PRIVMSG",
|
||||||
tags={"+baz": "a" * 4081, "msgid": StrRe(".+"), **ANYDICT},
|
params=["#test", StrRe("b{400,496}")],
|
||||||
)
|
tags={"+baz": "a" * 4081, "msgid": StrRe(".+"), **ANYDICT},
|
||||||
self.assertEqual(echo.tags["msgid"], relay.tags["msgid"])
|
)
|
||||||
# message may have been truncated
|
self.assertMessageMatch(
|
||||||
self.assertIn("b" * 400, echo.params[1])
|
relay,
|
||||||
self.assertEqual(echo.params[1].rstrip("b"), "")
|
command="PRIVMSG",
|
||||||
self.assertIn("b" * 400, relay.params[1])
|
params=["#test", StrRe("b{400,496}")],
|
||||||
self.assertEqual(relay.params[1].rstrip("b"), "")
|
tags={"+baz": "a" * 4081, "msgid": StrRe(".+"), **ANYDICT},
|
||||||
|
)
|
||||||
|
self.assertEqual(echo.tags["msgid"], relay.tags["msgid"])
|
||||||
|
# message may have been truncated
|
||||||
|
self.assertIn("b" * 400, echo.params[1])
|
||||||
|
self.assertEqual(echo.params[1].rstrip("b"), "")
|
||||||
|
self.assertIn("b" * 400, relay.params[1])
|
||||||
|
self.assertEqual(relay.params[1].rstrip("b"), "")
|
||||||
|
|
||||||
excess_privmsg = "@foo=bar;+baz=%s PRIVMSG #test %s" % ("a" * 4082, "b" * 495)
|
excess_privmsg = "@foo=bar;+baz=%s PRIVMSG #test %s" % ("a" * 4082, "b" * 495)
|
||||||
# TAGMSG data is over the limit, but we're within the overall limit for a line
|
# TAGMSG data is over the limit, but we're within the overall limit for a line
|
||||||
|
Reference in New Issue
Block a user