python-discord / bot

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

Newline antispam filter potentially handles actual rendered lines of formatting incorrectly #3037

Open thatbirdguythatuknownot opened 6 months ago

thatbirdguythatuknownot commented 6 months ago

Due to a recent incident, it is very important to note the need to special-case codeblocks' newline count for the antispam filter. image It is important to note that, as shown in the image, a codeblock renders about 2 extra lines worth of space compared to a regular text line. It is also recommended to special-case headers, as they make text a lot larger than usual (although I haven't computed it yet).

ChrisLovering commented 6 months ago

There's quite a lot of features of this bot that interact with codeblocks, so this issue doesn't give us much to go off of for potentially fixing what you believe to be incorrect.

Could you specify where we should special case this count?

It might be easier if you provide reproduction steps, what the expected behaviour is, and what the current behaviour is.

If you believe this is an exploitable bug and shouldn't be discussed publicly, please follow our security notice

thatbirdguythatuknownot commented 6 months ago

There was recently an incident with spam in #python-discussion where a user sent a lot of backticks that turned into codeblocks that flooded the chat. I think the relevant code is here.

ChrisLovering commented 6 months ago

So just to be clear then, this issue is related to the new lines filter potentially not working correctly for messages with backticks?

If so, could you update the original description & title to reflect that?

thatbirdguythatuknownot commented 6 months ago

Yup.