mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 04:23:46 +00:00
markdown: Catch OverflowErrors in global times.
This also matches the except in the block above.
This commit is contained in:
committed by
Tim Abbott
parent
89bc073b5b
commit
d2464ff52b
@@ -1,4 +1,4 @@
|
||||
import {isValid} from "date-fns";
|
||||
import {getUnixTime, isValid} from "date-fns";
|
||||
import katex from "katex";
|
||||
import _ from "lodash";
|
||||
import assert from "minimalistic-assert";
|
||||
@@ -580,7 +580,7 @@ function handleTimestamp(time_string: string): string {
|
||||
}
|
||||
|
||||
const escaped_time = _.escape(time_string);
|
||||
if (!isValid(timeobject)) {
|
||||
if (!isValid(timeobject) || getUnixTime(timeobject) < 0) {
|
||||
// Unsupported time format: rerender accordingly.
|
||||
|
||||
// We do not show an error on these formats in local echo because
|
||||
|
||||
@@ -1455,7 +1455,7 @@ class Timestamp(markdown.inlinepatterns.Pattern):
|
||||
if timestamp.tzinfo:
|
||||
try:
|
||||
timestamp = timestamp.astimezone(timezone.utc)
|
||||
except ValueError:
|
||||
except (ValueError, OverflowError):
|
||||
error_element = Element("span")
|
||||
error_element.set("class", "timestamp-error")
|
||||
error_element.text = markdown.util.AtomicString(
|
||||
|
||||
@@ -845,6 +845,13 @@
|
||||
"marked_expected_output": "<p><span>1969-12-31T00:00:00+32:00</span></p>",
|
||||
"text_content": "Invalid time format: 1969-12-31T00:00:00+32:00"
|
||||
},
|
||||
{
|
||||
"name": "timestamp_overflow",
|
||||
"input": "<time:0001-01-01T01:00:00+02:00>",
|
||||
"expected_output": "<p><span class=\"timestamp-error\">Invalid time format: 0001-01-01T01:00:00+02:00</span></p>",
|
||||
"marked_expected_output": "<p><span>0001-01-01T01:00:00+02:00</span></p>",
|
||||
"text_content": "Invalid time format: 0001-01-01T01:00:00+02:00"
|
||||
},
|
||||
{
|
||||
"name": "timestamp_unix",
|
||||
"input": "Let's meet at <time:1496701800>.",
|
||||
|
||||
Reference in New Issue
Block a user