aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar GDWR <[email protected]>2022-05-10 18:49:12 +0100
committerGravatar GDWR <[email protected]>2022-05-10 18:49:12 +0100
commitc9daa6f3774380794968cf28faf9ba4bde1f68e2 (patch)
treedda7670a31b2c078a34ba0195533f526a6361f7f
parentAdd tests for `DISCORD_INVITE` regex (diff)
`DISCORD_INVITE` captures until a whitespace
-rw-r--r--botcore/utils/regex.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/botcore/utils/regex.py b/botcore/utils/regex.py
index abcaf299..5146a113 100644
--- a/botcore/utils/regex.py
+++ b/botcore/utils/regex.py
@@ -11,13 +11,17 @@ DISCORD_INVITE = re.compile(
r"discord([.,]|dot)io|" # or discord.io.
r"((?<!\w)([.,]|dot))gg" # or .gg/
r")([/]|slash)" # / or 'slash'
- r"(?P<invite>[a-zA-Z0-9\-]+)", # the invite code itself
+ r"(?P<invite>\S+)", # the invite code itself
flags=re.IGNORECASE
)
"""
Regex for Discord server invites.
:meta hide-value:
+.. warning::
+ This regex pattern will capture until a whitespace, if you are to use the 'invite' capture group in
+ any HTTP requests or similar. Please ensure you sanitise the output using something similar to
+ https://docs.python.org/3/library/urllib.parse.html#urllib.parse.quote.
"""
FORMATTED_CODE_REGEX = re.compile(