summaryrefslogtreecommitdiff
path: root/src/bridge
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2016-06-21 23:15:25 +0100
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2016-06-21 23:15:25 +0100
commit0391f17f999618decffaf3c9261024ab04a33f63 (patch)
treede11883022c2342200cbdf5593b8da5acff97a3e /src/bridge
parent350d48a5bf2412f5eee347fc832d9257b2ba3fbc (diff)
downloadbiboumi-0391f17f999618decffaf3c9261024ab04a33f63.tar.gz
biboumi-0391f17f999618decffaf3c9261024ab04a33f63.tar.bz2
biboumi-0391f17f999618decffaf3c9261024ab04a33f63.tar.xz
biboumi-0391f17f999618decffaf3c9261024ab04a33f63.zip
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.
Diffstat (limited to 'src/bridge')
-rw-r--r--src/bridge/bridge.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp
index 3a7a147..87667db 100644
--- a/src/bridge/bridge.cpp
+++ b/src/bridge/bridge.cpp
@@ -685,7 +685,10 @@ void Bridge::send_user_join(const std::string& hostname, const std::string& chan
std::string role;
std::tie(role, affiliation) = get_role_affiliation_from_irc_mode(user_mode);
- this->xmpp.send_user_join(chan_name + utils::empty_if_fixed_server("%" + hostname), user->nick, user->host,
+ std::string encoded_chan_name(chan_name);
+ xep0106::encode(encoded_chan_name);
+
+ this->xmpp.send_user_join(encoded_chan_name + utils::empty_if_fixed_server("%" + hostname), user->nick, user->host,
affiliation, role, this->user_jid + "/" + resource, self);
}
@@ -701,8 +704,10 @@ void Bridge::send_topic(const std::string& hostname, const std::string& chan_nam
const std::string& topic, const std::string& who,
const std::string& resource)
{
- const auto encoding = in_encoding_for(*this, {chan_name + '%' + hostname});
- this->xmpp.send_topic(chan_name + utils::empty_if_fixed_server(
+ std::string encoded_chan_name(chan_name);
+ xep0106::encode(encoded_chan_name);
+ const auto encoding = in_encoding_for(*this, {encoded_chan_name + '%' + hostname});
+ this->xmpp.send_topic(encoded_chan_name + utils::empty_if_fixed_server(
"%" + hostname), this->make_xmpp_body(topic, encoding), this->user_jid + "/" + resource, who);
}
@@ -884,13 +889,13 @@ void Bridge::generate_channel_join_for_resource(const Iid& iid, const std::strin
if (user->nick != self->nick)
{
log_debug(user->nick);
- this->send_user_join(iid.get_server(), iid.get_local(),
+ this->send_user_join(iid.get_server(), iid.get_encoded_local(),
user.get(), user->get_most_significant_mode(irc->get_sorted_user_modes()),
false, resource);
}
}
- this->send_user_join(iid.get_server(), iid.get_local(),
+ this->send_user_join(iid.get_server(), iid.get_encoded_local(),
self, self->get_most_significant_mode(irc->get_sorted_user_modes()),
true, resource);
- this->send_topic(iid.get_server(), iid.get_local(), channel->topic, channel->topic_author, resource);
+ this->send_topic(iid.get_server(), iid.get_encoded_local(), channel->topic, channel->topic_author, resource);
}