Commit 25423ffd authored by louiz’'s avatar louiz’

Merge branch 'patch-1' into 'master'

Change max line length to more conservative constants

See merge request louiz/biboumi!21
parents 70ecb0f0 435a63a0
...@@ -483,12 +483,16 @@ bool IrcClient::send_channel_message(const std::string& chan_name, const std::st ...@@ -483,12 +483,16 @@ bool IrcClient::send_channel_message(const std::string& chan_name, const std::st
} }
// The max size is 512, taking into account the whole message, not just // The max size is 512, taking into account the whole message, not just
// the text we send. // the text we send.
// This includes our own nick, username and host (because this will be // This includes our own nick, constants for username and host (because these
// added by the server into our message), in addition to the basic // are notoriously hard to know what the server will use), in addition to the basic
// components of the message we send (command name, chan name, \r\n et) // components of the message we send (command name, chan name, \r\n etc.)
// : + NICK + ! + USER + @ + HOST + <space> + PRIVMSG + <space> + CHAN + <space> + : + \r\n // : + NICK + ! + USER + @ + HOST + <space> + PRIVMSG + <space> + CHAN + <space> + : + \r\n
// 63 is the maximum hostname length defined by the protocol. 10 seems to be
// the username limit.
constexpr auto max_username_size = 10;
constexpr auto max_hostname_size = 63;
const auto line_size = 512 - const auto line_size = 512 -
this->current_nick.size() - this->username.size() - this->own_host.size() - this->current_nick.size() - max_username_size - max_hostname_size -
::strlen(":!@ PRIVMSG ") - chan_name.length() - ::strlen(" :\r\n"); ::strlen(":!@ PRIVMSG ") - chan_name.length() - ::strlen(" :\r\n");
const auto lines = cut(body, line_size); const auto lines = cut(body, line_size);
for (const auto& line: lines) for (const auto& line: lines)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment