fix: reject stray pipe in sign by using [+-] character class
Inside a character class '|' is a literal, so [+|-] matched '+', '-', or '|'. A leading pipe was captured as a sign and stripped, letting malformed input like '|5m' parse to 300 instead of returning None. Restrict the class to the two intended sign characters.
This commit is contained in:
1 parent
9b5ce3ede3
commit
a0b5007d40
2 files changed
+5
-1
No files matched your search
@@ -33,7 +33,7 @@ kinds of time expressions.
|
||||
|
||||
import re
|
||||
|
||||
SIGN = r'(?P<sign>[+|-])?'
|
||||
SIGN = r'(?P<sign>[+-])?'
|
||||
#YEARS = r'(?P<years>\d+)\s*(?:ys?|yrs?.?|years?)'
|
||||
#MONTHS = r'(?P<months>\d+)\s*(?:mos?.?|mths?.?|months?)'
|
||||
WEEKS = r'(?P<weeks>[\d.]+)\s*(?:w|wks?|weeks?)'
|
||||
|
||||
Reference in new issue
Block a user