Commit ad0465b3 authored by louiz’'s avatar louiz’

Decode incoming JIDs local part according to xep 0106

This let users send message to nicks such as Q@CServe.quakenet.org

fix #3047
parent d5324ac7
louloulibs @ 88d2b136
Subproject commit 99757a44b49619ff59cae9e6d983a3b7c20c56bf Subproject commit 88d2b136e5f133f0d0dc01f59449284f663d53ea
#include <utils/tolower.hpp> #include <utils/tolower.hpp>
#include <config/config.hpp> #include <config/config.hpp>
#include <utils/encoding.hpp>
#include <irc/iid.hpp> #include <irc/iid.hpp>
...@@ -68,6 +69,7 @@ Iid::Iid(): ...@@ -68,6 +69,7 @@ Iid::Iid():
void Iid::set_local(const std::string& loc) void Iid::set_local(const std::string& loc)
{ {
this->local = utils::tolower(loc); this->local = utils::tolower(loc);
xep0106::decode(local);
} }
void Iid::set_server(const std::string& serv) void Iid::set_server(const std::string& serv)
......
...@@ -396,7 +396,15 @@ int main() ...@@ -396,7 +396,15 @@ int main()
assert(iid6.get_server() == "fixed.example.com"); assert(iid6.get_server() == "fixed.example.com");
assert(iid6.is_channel); assert(iid6.is_channel);
assert(!iid6.is_user); assert(!iid6.is_user);
Config::set("fixed_irc_server", "", false);
} }
std::cout << color << "Testing JID (xep 0106) decoding…" << reset << std::endl;
assert(Iid{"space\\20cadet!"}.get_local() == "space cadet");
assert(Iid{"call\\20me\\20\\22ishmael\\22!"}.get_local() == "call me \"ishmael\"");
assert(Iid{"\\2f.fanboy!"}.get_local() == "/.fanboy");
assert(Iid{"Q\\40CServe.quakenet.org!"}.get_local() == "q@cserve.quakenet.org");
return 0; return 0;
} }
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