markdown: Prevent OverflowError with large time integers.

`<time:1234567890123>` causes a "signed integer is greater than
maximum" exception from dateutil.parser; datetime also cannot handle
it ("year 41091 is out of range") but that is a ValueError which is
already caught.

Catch the OverflowError thrown by dateutil.
This commit is contained in:
Alex Vandiver
2024-01-05 14:38:08 +00:00
committed by Tim Abbott
parent af3b15ef10
commit 4ab9cd7cf2
2 changed files with 8 additions and 1 deletions

View File

@@ -1395,7 +1395,7 @@ class Timestamp(markdown.inlinepatterns.Pattern):
time_input_string = match.group("time")
try:
timestamp = dateutil.parser.parse(time_input_string, tzinfos=common_timezones)
except ValueError:
except (ValueError, OverflowError):
try:
timestamp = datetime.fromtimestamp(float(time_input_string), tz=timezone.utc)
except ValueError: