diff options
| author | 2020-05-15 08:54:36 -0700 | |
|---|---|---|
| committer | 2020-05-15 08:55:21 -0700 | |
| commit | 4a73c24678d4a893304f0b2f3a5f1e326cae817a (patch) | |
| tree | 2b0c7d1dbbefa58724e73034734836b7ae84f3d3 | |
| parent | Token remover: fix timestamp check (diff) | |
Token remover: use strict check for digits in token ID
`isnumeric` would be true for a wide range of characters in Unicode,
but the ID must only consist of the characters 0-9 (ASCII digits). In
fact, `isdigit` on its own would also match other Unicode characters
too.
| -rw-r--r-- | bot/cogs/token_remover.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/bot/cogs/token_remover.py b/bot/cogs/token_remover.py index 957c8a690..43c12c4f7 100644 --- a/bot/cogs/token_remover.py +++ b/bot/cogs/token_remover.py @@ -149,8 +149,11 @@ class TokenRemover(Cog): b64_content += '=' * (-len(b64_content) % 4) try: - content: bytes = base64.b64decode(b64_content) - return content.decode('utf-8').isnumeric() + decoded_bytes: bytes = base64.b64decode(b64_content) + string = decoded_bytes.decode('utf-8') + + # isdigit on its own would match a lot of other Unicode characters, hence the isascii. + return string.isascii() and string.isdigit() except (binascii.Error, ValueError): return False |