mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
Prevent unexpected timedelta matches (#5393)
* Prevent unexpected matches by asserting whitespace or eof at the end of matches * Use a positive lookahead instead of a capturing group to support 1d6h syntax * Use fullmatch instead of modifying regex strings
This commit is contained in:
parent
9c05db1104
commit
dce2378806
@ -76,7 +76,7 @@ def _parse_and_match(string_to_match: str, allowed_units: List[str]) -> Optional
|
||||
"""
|
||||
Local utility function to match TIME_RE string above to user input for both parse_timedelta and parse_relativedelta
|
||||
"""
|
||||
matches = TIME_RE.match(string_to_match)
|
||||
matches = TIME_RE.fullmatch(string_to_match)
|
||||
if matches:
|
||||
params = {k: int(v) for k, v in matches.groupdict().items() if v is not None}
|
||||
for k in params.keys():
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user