diff options
author | Florent Le Coz <louiz@louiz.org> | 2014-05-14 21:48:38 +0200 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2014-05-14 21:48:38 +0200 |
commit | 712b7bdfdfe5d77001669dd1d11a860437dc3849 (patch) | |
tree | e21c66d59d35197ff6ec3fcdd6369760b07386f1 /src/irc | |
parent | 634e7cf125a8870f49b3c99364d710b0da98decf (diff) | |
download | biboumi-712b7bdfdfe5d77001669dd1d11a860437dc3849.tar.gz biboumi-712b7bdfdfe5d77001669dd1d11a860437dc3849.tar.bz2 biboumi-712b7bdfdfe5d77001669dd1d11a860437dc3849.tar.xz biboumi-712b7bdfdfe5d77001669dd1d11a860437dc3849.zip |
Correctly handle the usage of ! as a IRC user mode indicator
Since “!” is also the separator between the nickname and the user hostname,
having “!” as the user mode (e.g. !nick!~some@host.bla) would cause the nick
to be empty. Now we skip it if it is a valid user mode indicator.
Diffstat (limited to 'src/irc')
-rw-r--r-- | src/irc/irc_user.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/irc/irc_user.cpp b/src/irc/irc_user.cpp index 0f1b1ee..8785270 100644 --- a/src/irc/irc_user.cpp +++ b/src/irc/irc_user.cpp @@ -7,14 +7,14 @@ IrcUser::IrcUser(const std::string& name, { if (name.empty()) return ; - const std::string::size_type sep = name.find("!"); const std::map<char, char>::const_iterator prefix = prefix_to_mode.find(name[0]); - const size_t name_begin = prefix == prefix_to_mode.end()? 0: 1; + const std::string::size_type name_begin = prefix == prefix_to_mode.end()? 0: 1; + const std::string::size_type sep = name.find("!", name_begin); if (sep == std::string::npos) this->nick = name.substr(name_begin); else { - this->nick = name.substr(name_begin, sep); + this->nick = name.substr(name_begin, sep-name_begin); this->host = name.substr(sep+1); } if (prefix != prefix_to_mode.end()) |