1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-10-18 20:25:59 +02:00

[muc] Prevent duplicate processing of mediated invitations

MUC mediated invitations usually have the form

<message
    from='coven@chat.shakespeare.lit'
    id='nzd143v8'
    to='hecate@shakespeare.lit'>
  <x xmlns='http://jabber.org/protocol/muc#user'>
    <invite from='crone1@shakespeare.lit/desktop'>
      <reason>
        Hey Hecate, this is the place for all good witches!
      </reason>
    </invite>
    <password>cauldronburn</password>
  </x>
</message>
(source: XEP-0045 Example 57.)

However, previous versions of XEP-0045 specified an additional <x
xmlns='jabberconference'> element to be included (see
implementation note in XEP-0045). Therefore, a legacy implementation
may emit a mediated invitations in the form of

<message
    from="smack-inttest-mediated-invite-from-8ta77-hw9igz@conference.example.org"
	to="smack-inttest-two-8ta77@example.org">
  <x xmlns="http://jabber.org/protocol/muc#user">
    <invite from="smack-inttest-one-8ta77@example.org"/>
  </x>
  <x xmlns="jabberconference" jid="smack-inttest-mediated-invite-from-8ta77-hw9igz@conference.example.org"/>
</message>

Unfortunately, this matches
MultiUserChatManager.DIRECT_INVITATION_FILTER because
GroupChatInvitation matches <x xmlns="jabberconference"/>. However
the message is not a direct invitation but a mediated one. Besides
this invoking the wrong listeners (direct vs. medidated) the value for
'inviter' that's used to invoke that listener will be false.

To fix this, extend DIRECT_INVITATION_FILTER with
NotFilter.of(MUCUser.class) to avoid matching those legacy mediated
invitations.

Fixes SMACK-943

Co-authored-by: Florian Schmaus <flo@geekplace.eu>
This commit is contained in:
Guus der Kinderen 2024-06-14 22:25:05 +02:00 committed by Florian Schmaus
parent 0bb3bf292c
commit 98dbc0ee2e

View file

@ -148,6 +148,7 @@ public final class MultiUserChatManager extends Manager {
private static final StanzaFilter DIRECT_INVITATION_FILTER = private static final StanzaFilter DIRECT_INVITATION_FILTER =
new AndFilter(StanzaTypeFilter.MESSAGE, new AndFilter(StanzaTypeFilter.MESSAGE,
new ExtensionElementFilter<GroupChatInvitation>(GroupChatInvitation.class), new ExtensionElementFilter<GroupChatInvitation>(GroupChatInvitation.class),
NotFilter.of(MUCUser.class),
new NotFilter(MessageTypeFilter.ERROR)); new NotFilter(MessageTypeFilter.ERROR));
private static final ExpirationCache<DomainBareJid, DiscoverInfo> KNOWN_MUC_SERVICES = new ExpirationCache<>( private static final ExpirationCache<DomainBareJid, DiscoverInfo> KNOWN_MUC_SERVICES = new ExpirationCache<>(