mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 04:53:36 +00:00
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:
committed by
Tim Abbott
parent
af3b15ef10
commit
4ab9cd7cf2
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user