Add XEP-0106 support to the bridge

This allows the user to join channels containing forbidden characters
in the local part, like #r&d or #group/project.
This commit is contained in:
Emmanuel Gil Peyrot
2016-06-21 23:15:25 +01:00
parent 350d48a5bf
commit 0391f17f99
3 changed files with 27 additions and 10 deletions
+15 -4
View File
@@ -3,6 +3,8 @@
#include <irc/iid.hpp>
#include <utils/encoding.hpp>
Iid::Iid(const std::string& iid):
is_channel(false),
is_user(false)
@@ -59,7 +61,9 @@ Iid::Iid():
void Iid::set_local(const std::string& loc)
{
this->local = utils::tolower(loc);
std::string local(utils::tolower(loc));
xep0106::decode(local);
this->local = local;
}
void Iid::set_server(const std::string& serv)
@@ -72,6 +76,13 @@ const std::string& Iid::get_local() const
return this->local;
}
const std::string Iid::get_encoded_local() const
{
std::string local(this->local);
xep0106::encode(local);
return local;
}
const std::string& Iid::get_server() const
{
return this->server;
@@ -90,13 +101,13 @@ namespace std {
const std::string to_string(const Iid& iid)
{
if (Config::get("fixed_irc_server", "").empty())
return iid.get_local() + iid.get_sep() + iid.get_server();
return iid.get_encoded_local() + iid.get_sep() + iid.get_server();
else
{
if (iid.get_sep() == "!")
return iid.get_local() + iid.get_sep();
return iid.get_encoded_local() + iid.get_sep();
else
return iid.get_local();
return iid.get_encoded_local();
}
}
}