Skip to content

Commit 16441a1

Browse files
authored
Don't ignore newlines when filtering invites (#3207)
1 parent f229e5f commit 16441a1

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

bot/exts/filtering/_filter_lists/invite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ async def actions_for(
6060
self, ctx: FilterContext
6161
) -> tuple[ActionSettings | None, list[str], dict[ListType, list[Filter]]]:
6262
"""Dispatch the given event to the list's filters, and return actions to take and messages to relay to mods."""
63-
text = clean_input(ctx.content)
63+
text = clean_input(ctx.content, keep_newlines=True)
6464

6565
matches = list(DISCORD_INVITE.finditer(text))
6666
invite_codes = {m.group("invite") for m in matches}

bot/exts/filtering/_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def subclasses_in_package(package: str, prefix: str, parent: T) -> set[T]:
5151
return subclasses
5252

5353

54-
def clean_input(string: str) -> str:
54+
def clean_input(string: str, *, keep_newlines: bool = False) -> str:
5555
"""Remove zalgo and invisible characters from `string`."""
5656
# For future consideration: remove characters in the Mc, Sk, and Lm categories too.
5757
# Can be normalised with form C to merge char + combining char into a single char to avoid
@@ -60,8 +60,8 @@ def clean_input(string: str) -> str:
6060

6161
# URL quoted strings can be used to hide links to servers
6262
content = urllib.parse.unquote(content)
63-
# Drop newlines that can be used to bypass filter
64-
content = content.replace("\n", "")
63+
if not keep_newlines: # Drop newlines that can be used to bypass filter
64+
content = content.replace("\n", "")
6565
# Avoid escape characters
6666
content = content.replace("\\", "")
6767

0 commit comments

Comments
 (0)