python-discord / bot

The community bot for the Python Discord community
https://pythondiscord.com
MIT License
1.34k stars 666 forks source link

new invite regex allows invites to other servers #2547

Open onerandomusername opened 1 year ago

onerandomusername commented 1 year ago

https://github.com/python-discord/bot/pull/2522 opens some regressions in the invite filter which allow users to send invites in the server that go to other servers. This is due to how discord fetches invites, and how the invite parser now works.

This was originally fixed by https://github.com/python-discord/bot/pull/2173 and is a new regression.

A simple example is as follows:

mbaruh commented 1 year ago

The simplest solution to this is probably to limit the trimming only to non-word characters at the end of the string, meaning https://github.com/python-discord/bot/blob/85bafc39cc420d6c6d07dd84f1cebb0482f2a1e1/bot/exts/filtering/_filter_lists/invite.py#L24 can be changed to [^a-zA-Z0-9/]* (untested).

We can do this specifically for the whitelist and keep the blacklist trimming as-is, but this is probably an unnecessary resolution.

EDIT: This will also mean that the pattern should be matched instead of searched.