IRC nicks cannot contain spaces
Rather than trying and hoping the server gives a proper failure, just fail early and avoid the whole mess. Some servers will instead send messages to the user, etc, which is not very helpful.
This commit is contained in:
@@ -526,6 +526,11 @@ void IrcClient::send_user_command(const std::string& username, const std::string
|
||||
|
||||
void IrcClient::send_nick_command(const std::string& nick)
|
||||
{
|
||||
if (nick.find(' ') != std::string::npos)
|
||||
{
|
||||
this->on_erroneous_nickname(IrcMessage(std::string(this->hostname), "432", {this->get_own_nick(), nick, "Erroneous nickname"}));
|
||||
return;
|
||||
}
|
||||
this->send_message(IrcMessage("NICK", {nick}));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
from scenarios import *
|
||||
|
||||
scenario = (
|
||||
send_stanza("<presence from='{jid_one}/{resource_one}' to='#foo%{irc_server_one}/{nick_one}' ><x xmlns='http://jabber.org/protocol/muc'/></presence>"),
|
||||
sequences.connection(),
|
||||
expect_stanza("/presence[@to='{jid_one}/{resource_one}'][@from='#foo%{irc_server_one}/{nick_one}']/muc_user:x/muc_user:item[@affiliation='admin'][@role='moderator']",
|
||||
"/presence/muc_user:x/muc_user:status[@code='110']"),
|
||||
expect_stanza("/message[@from='#foo%{irc_server_one}'][@type='groupchat']/subject[not(text())]"),
|
||||
|
||||
# Attempt to change nick to a nickname containing a space
|
||||
send_stanza("<presence from='{jid_one}/{resource_one}' to='#foo%{irc_server_one}/Nick With Space' />"),
|
||||
expect_stanza("/message[@from='{irc_server_one}'][@to='{jid_one}/{resource_one}']/body[text()='irc.localhost: Erroneous nickname: Nick With Space']"),
|
||||
)
|
||||
Reference in New Issue
Block a user