From dce2378806b251ba14ac146d973b4b3e3500b314 Mon Sep 17 00:00:00 2001 From: Flame442 <34169552+Flame442@users.noreply.github.com> Date: Wed, 29 Dec 2021 18:46:36 -0500 Subject: [PATCH] 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 --- redbot/core/commands/converter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redbot/core/commands/converter.py b/redbot/core/commands/converter.py index 43c41cb15..9c96be703 100644 --- a/redbot/core/commands/converter.py +++ b/redbot/core/commands/converter.py @@ -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():