summaryrefslogtreecommitdiff
path: root/src/irc
diff options
context:
space:
mode:
authorAilin Nemui <ailin.nemui@gmail.com>2018-01-10 13:36:53 +0100
committerAilin Nemui <ailin.nemui@gmail.com>2018-01-10 13:36:53 +0100
commit435a63a070e62a11b0a6f5a3c06c445e1a79b9f5 (patch)
tree79b9709ecd287fc9391e85665f96acc5397d847d /src/irc
parent70ecb0f0d43f75da89ecfa2857aac67aafda136f (diff)
downloadbiboumi-435a63a070e62a11b0a6f5a3c06c445e1a79b9f5.tar.gz
biboumi-435a63a070e62a11b0a6f5a3c06c445e1a79b9f5.tar.bz2
biboumi-435a63a070e62a11b0a6f5a3c06c445e1a79b9f5.tar.xz
biboumi-435a63a070e62a11b0a6f5a3c06c445e1a79b9f5.zip
Change max line length to more conservative constants
Diffstat (limited to 'src/irc')
-rw-r--r--src/irc/irc_client.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp
index 5f26bf0..40078d9 100644
--- a/src/irc/irc_client.cpp
+++ b/src/irc/irc_client.cpp
@@ -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 text we send.
- // This includes our own nick, username and host (because this will be
- // added by the server into our message), in addition to the basic
- // components of the message we send (command name, chan name, \r\n et)
+ // This includes our own nick, constants for username and host (because these
+ // 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 etc.)
// : + 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 -
- 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");
const auto lines = cut(body, line_size);
for (const auto& line: lines)