| author | Eric Roberts
<eric@devl.me> 2026-11-18 15:49:54 UTC |
| committer | Eric Roberts
<eric@devl.me> 2026-11-18 15:49:54 UTC |
| parent | 8e74e19c8530c810f4f294070ededbc8f545d82c |
| borogove/Chat.hx | +1 | -1 |
| test/TestChat.hx | +29 | -0 |
diff --git a/borogove/Chat.hx b/borogove/Chat.hx index 0d76b09..dbfba36 100644 --- a/borogove/Chat.hx +++ b/borogove/Chat.hx @@ -998,7 +998,7 @@ abstract class Chat extends EventEmitter { resolve((itemsGet.getResult() ?? []).filter(item -> // Remove advertisement of commands at other JIDs for now // It's a potential security/privacy issue depending on UX - item.jid != null && item.jid.asBare().equals(jid) && item.node != null + item.jid != null && item.jid.asBare().equals(bareJid) && item.node != null ).map(item -> new Command(client, item))); }); client.sendQuery(itemsGet); diff --git a/test/TestChat.hx b/test/TestChat.hx index 1953398..45e9f28 100644 --- a/test/TestChat.hx +++ b/test/TestChat.hx @@ -415,6 +415,35 @@ class TestChat extends utest.Test { chat.moderate(message, "Spam"); } + public function testCommandsFromResourceFiltersByBareJid(async: Async) { + final client = new Client("test@example.com", new Dummy()); + final chat = client.getDirectChat("friend@example.com"); + final caps = new borogove.Caps("", [], ["http://jabber.org/protocol/commands"], []); + chat.presence.set("desktop", new Presence(caps, null, null)); + client.capsRepo.add(caps); + + client.stream.on("sendStanza", (stanza: Stanza) -> { + Assert.equals("friend@example.com/desktop", stanza.attr.get("to")); + client.stream.onStanza( + new Stanza("iq", { + xmlns: "jabber:client", + type: "result", + id: stanza.attr.get("id"), + from: stanza.attr.get("to") + }).tag("query", { xmlns: "http://jabber.org/protocol/disco#items" }) + .tag("item", { jid: "friend@example.com", node: "same-account" }).up() + .tag("item", { jid: "other@example.com/desktop", node: "other-account" }).up() + .up() + ); + return EventHandled; + }); + + chat.commands().then(commands -> { + Assert.same(["same-account"], commands.map(command -> command.node)); + async.done(); + }); + } + public function testChannelCommandsReturnsSettingsForOwner(async: Async) { final persistence = new Dummy(); final client = new Client("test@example.com", persistence);