Skip to content

fixes #146: Limit URI template match for MUC affiliation#147

Merged
guusdk merged 2 commits intoigniterealtime:mainfrom
guusdk:146_muc-affiliation-uri-template-clash
Aug 4, 2022
Merged

fixes #146: Limit URI template match for MUC affiliation#147
guusdk merged 2 commits intoigniterealtime:mainfrom
guusdk:146_muc-affiliation-uri-template-clash

Conversation

@guusdk
Copy link
Copy Markdown
Member

@guusdk guusdk commented Aug 4, 2022

The fix for issue #141 introduces a template to replace four distinct URL patterns:

  • /restapi/v1/chatrooms/{roomName}/owners
  • /restapi/v1/chatrooms/{roomName}/admins
  • /restapi/v1/chatrooms/{roomName}/members
  • /restapi/v1/chatrooms/{roomName}/outcasts

got replaced by

  • /restapi/v1/chatrooms/{roomName}/{affiliation}

Sadly, this template matches more than just those four. URLs like these also get caught, making them misbehave:

  • /restapi/v1/chatrooms/{roomName}/chathistory
  • /restapi/v1/chatrooms/{roomName}/occupants
  • /restapi/v1/chatrooms/{roomName}/participants
  • /restapi/v1/chatrooms/{roomName}/invite

This commit fixes the problem by applying a regular expression to the {affiliation} template, requiring it to match one of four distinct options.

Also introduces a fix for #148 by introducing a distinct new entity used to post data, rather than re-use an existing one that got an additional, optional parameter.

The fix for issue igniterealtime#141 introduces a template to replace four distinct URL patterns:
- `/restapi/v1/chatrooms/{roomName}/owners`
- `/restapi/v1/chatrooms/{roomName}/admins`
- `/restapi/v1/chatrooms/{roomName}/members`
- `/restapi/v1/chatrooms/{roomName}/outcasts`

got replaced by

- `/restapi/v1/chatrooms/{roomName}/{affiliation}`

Sadly, this template matches more than just those four. URLs like these also get caught, making them misbehave:

- `/restapi/v1/chatrooms/{roomName}/chathistory`
- `/restapi/v1/chatrooms/{roomName}/occupants`
- `/restapi/v1/chatrooms/{roomName}/participants`
- `/restapi/v1/chatrooms/{roomName}/invite`

This commit fixes the problem by applying a regular expression to the `{affiliation}` template, requiring it to match one of four distinct options.
@guusdk guusdk force-pushed the 146_muc-affiliation-uri-template-clash branch from 03de927 to 7aa8c5d Compare August 4, 2022 13:15
…acters.

This was a result of trying to make the same entity usable for the pre-exising 'invite' endpoint (that works with just one JID), as well as for the new 'invite' endpoint (that can use a collection of JIDs). This introduced a list-of-JID field to the entity, which obviously should not be used for the singular-type endpoint.

In this commit, I've introduced distinct entities to be used for each endpoint, to clear up any confusion. The old entity was reverted to its original state. The new entity inherits from the old endpoint, and adds the 'list-of-jids-to-invite' field.
@guusdk guusdk force-pushed the 146_muc-affiliation-uri-template-clash branch from 7aa8c5d to b3fd94f Compare August 4, 2022 13:34
@guusdk guusdk requested a review from Fishbowler August 4, 2022 13:39
@guusdk guusdk merged commit ba1b638 into igniterealtime:main Aug 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants