summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2018-06-19 21:31:11 +0200
committerlouiz’ <louiz@louiz.org>2018-06-19 21:33:33 +0200
commit21a79b7bad51e755cee2890aa6d0bec5dd45f901 (patch)
tree2cb8613bd3f2ecd5d94e4e540baa721ab221a50e /src
parentfc17ee078f9966a73e0b919cf2826726cbc08e1f (diff)
downloadbiboumi-21a79b7bad51e755cee2890aa6d0bec5dd45f901.tar.gz
biboumi-21a79b7bad51e755cee2890aa6d0bec5dd45f901.tar.bz2
biboumi-21a79b7bad51e755cee2890aa6d0bec5dd45f901.tar.xz
biboumi-21a79b7bad51e755cee2890aa6d0bec5dd45f901.zip
Reject messages from unjoined resources, with an error
fix #3346
Diffstat (limited to 'src')
-rw-r--r--src/bridge/bridge.hpp2
-rw-r--r--src/xmpp/biboumi_component.cpp15
2 files changed, 14 insertions, 3 deletions
diff --git a/src/bridge/bridge.hpp b/src/bridge/bridge.hpp
index 8e7d9d7..04397c6 100644
--- a/src/bridge/bridge.hpp
+++ b/src/bridge/bridge.hpp
@@ -316,7 +316,9 @@ private:
*/
void add_resource_to_chan(const ChannelKey& channel, const std::string& resource);
void remove_resource_from_chan(const ChannelKey& channel, const std::string& resource);
+public:
bool is_resource_in_chan(const ChannelKey& channel, const std::string& resource) const;
+private:
void remove_all_resources_from_chan(const ChannelKey& channel);
std::size_t number_of_resources_in_chan(const ChannelKey& channel) const;
diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp
index 852b13f..8d97d07 100644
--- a/src/xmpp/biboumi_component.cpp
+++ b/src/xmpp/biboumi_component.cpp
@@ -273,9 +273,10 @@ void BiboumiComponent::handle_message(const Stanza& stanza)
std::string error_type("cancel");
std::string error_name("internal-server-error");
- utils::ScopeGuard stanza_error([this, &from_str, &to_str, &id, &error_type, &error_name](){
+ std::string error_text{};
+ utils::ScopeGuard stanza_error([this, &from_str, &to_str, &id, &error_type, &error_name, &error_text](){
this->send_stanza_error("message", from_str, to_str, id,
- error_type, error_name, "");
+ error_type, error_name, error_text);
});
const XmlNode* body = stanza.get_child("body", COMPONENT_NS);
@@ -284,7 +285,15 @@ void BiboumiComponent::handle_message(const Stanza& stanza)
{
if (body && !body->get_inner().empty())
{
- bridge->send_channel_message(iid, body->get_inner(), id);
+ if (bridge->is_resource_in_chan(iid.to_tuple(), from.resource))
+ bridge->send_channel_message(iid, body->get_inner(), id);
+ else
+ {
+ error_type = "modify";
+ error_name = "not-acceptable";
+ error_text = "You are not a participant in this room.";
+ return;
+ }
}
const XmlNode* subject = stanza.get_child("subject", COMPONENT_NS);
if (subject)