Merge remote-tracking branch 'linkmauve/escaped-iid-support'

This commit is contained in:
louiz’
2016-06-23 22:17:08 +02:00
4 changed files with 28 additions and 11 deletions
+11 -6
View File
@@ -685,7 +685,10 @@ void Bridge::send_user_join(const std::string& hostname, const std::string& chan
std::string role; std::string role;
std::tie(role, affiliation) = get_role_affiliation_from_irc_mode(user_mode); 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); 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& topic, const std::string& who,
const std::string& resource) const std::string& resource)
{ {
const auto encoding = in_encoding_for(*this, {chan_name + '%' + hostname}); std::string encoded_chan_name(chan_name);
this->xmpp.send_topic(chan_name + utils::empty_if_fixed_server( 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); "%" + 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) if (user->nick != self->nick)
{ {
log_debug(user->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()), user.get(), user->get_most_significant_mode(irc->get_sorted_user_modes()),
false, resource); 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()), self, self->get_most_significant_mode(irc->get_sorted_user_modes()),
true, resource); 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);
} }
+1 -1
View File
@@ -54,7 +54,7 @@ public:
const std::string& get_jid() const; const std::string& get_jid() const;
std::string get_bare_jid() const; std::string get_bare_jid() const;
static Xmpp::body make_xmpp_body(const std::string& str, const std::string& encodin = "ISO-8859-1"); static Xmpp::body make_xmpp_body(const std::string& str, const std::string& encoding = "ISO-8859-1");
/*** /***
** **
** From XMPP to IRC. ** From XMPP to IRC.
+15 -4
View File
@@ -3,6 +3,8 @@
#include <irc/iid.hpp> #include <irc/iid.hpp>
#include <utils/encoding.hpp>
Iid::Iid(const std::string& iid): Iid::Iid(const std::string& iid):
is_channel(false), is_channel(false),
is_user(false) is_user(false)
@@ -59,7 +61,9 @@ Iid::Iid():
void Iid::set_local(const std::string& loc) 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) void Iid::set_server(const std::string& serv)
@@ -72,6 +76,13 @@ const std::string& Iid::get_local() const
return this->local; 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 const std::string& Iid::get_server() const
{ {
return this->server; return this->server;
@@ -90,13 +101,13 @@ namespace std {
const std::string to_string(const Iid& iid) const std::string to_string(const Iid& iid)
{ {
if (Config::get("fixed_irc_server", "").empty()) 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 else
{ {
if (iid.get_sep() == "!") if (iid.get_sep() == "!")
return iid.get_local() + iid.get_sep(); return iid.get_encoded_local() + iid.get_sep();
else else
return iid.get_local(); return iid.get_encoded_local();
} }
} }
} }
+1
View File
@@ -53,6 +53,7 @@ public:
void set_local(const std::string& loc); void set_local(const std::string& loc);
void set_server(const std::string& serv); void set_server(const std::string& serv);
const std::string& get_local() const; const std::string& get_local() const;
const std::string get_encoded_local() const;
const std::string& get_server() const; const std::string& get_server() const;
bool is_channel; bool is_channel;