From 712b7bdfdfe5d77001669dd1d11a860437dc3849 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Wed, 14 May 2014 21:48:38 +0200 Subject: Correctly handle the usage of ! as a IRC user mode indicator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/test.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/test.cpp') diff --git a/src/test.cpp b/src/test.cpp index 1056926..f624bc2 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -122,6 +123,22 @@ int main() assert(xml_escape(unescaped) == "'coucou'<cc>/&"gaga""); assert(xml_unescape(xml_escape(unescaped)) == unescaped); + /** + * Irc user parsing + */ + const std::map prefixes{{'!', 'a'}, {'@', 'o'}}; + + IrcUser user1("!nick!~some@host.bla", prefixes); + assert(user1.nick == "nick"); + assert(user1.host == "~some@host.bla"); + assert(user1.modes.size() == 1); + assert(user1.modes.find('a') != user1.modes.end()); + IrcUser user2("coucou!~other@host.bla", prefixes); + assert(user2.nick == "coucou"); + assert(user2.host == "~other@host.bla"); + assert(user2.modes.size() == 0); + assert(user2.modes.find('a') == user2.modes.end()); + /** * Colors conversion */ -- cgit v1.2.3