aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar ionite34 <[email protected]>2022-07-14 20:29:48 -0400
committerGravatar ionite34 <[email protected]>2022-07-14 20:29:48 -0400
commit1fc0bcf09c8c1cef7698c84e05d39fee909310be (patch)
treeb3b80374bd925664ade5cae4c076ced11527b7b7
parentUpdated usage of REGEX_EMOJI (diff)
Improved numerical matching safety
- Added ASCII flag to match pattern - Changed `isdigit` check to `isdecimal`
-rw-r--r--bot/exts/fun/uwu.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/bot/exts/fun/uwu.py b/bot/exts/fun/uwu.py
index 3e98ed2e..fa66d807 100644
--- a/bot/exts/fun/uwu.py
+++ b/bot/exts/fun/uwu.py
@@ -57,7 +57,7 @@ SUBSTITUTE_STUTTER = r"\g<1>\g<2>-\g<2>"
REGEX_NYA = re.compile(r"n([aeou][^aeiou])")
SUBSTITUTE_NYA = r"ny\1"
-REGEX_EMOJI = re.compile(r"<(a?)?:(\w+):(\d{18})>?")
+REGEX_EMOJI = re.compile(r"<(a?)?:(\w+):(\d{18})>?", re.ASCII)
@dataclass(frozen=True, eq=True)
@@ -79,7 +79,7 @@ class Emoji:
@classmethod
def from_match(cls, match: tuple[str, str, str]) -> t.Optional['Emoji']:
"""Creates an Emoji from a regex match tuple."""
- if not match or len(match) != 3 or not match[2].isdigit():
+ if not match or len(match) != 3 or not match[2].isdecimal():
return None
return cls(match[1], int(match[2]), match[0] == "a")