mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 18:36:36 +00:00
timestamp: Hide timestamp forrmat errors in local echo.
This commit is contained in:
committed by
Tim Abbott
parent
3d0a5d28f2
commit
0b510cd66d
@@ -305,7 +305,12 @@ function handleTimestamp(time) {
|
|||||||
const escaped_time = _.escape(time);
|
const escaped_time = _.escape(time);
|
||||||
if (timeobject === null || !timeobject.isValid()) {
|
if (timeobject === null || !timeobject.isValid()) {
|
||||||
// Unsupported time format: rerender accordingly.
|
// Unsupported time format: rerender accordingly.
|
||||||
return `<span class="timestamp-error">Invalid time format: ${escaped_time}</span>`;
|
|
||||||
|
// We do not show an error on these formats in local echo because
|
||||||
|
// there is a chance that the server would interpret it successfully
|
||||||
|
// and if it does, the jumping from the error message to a rendered
|
||||||
|
// timestamp doesn't look good.
|
||||||
|
return `<span>${escaped_time}</span>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use html5 <time> tag for valid timestamps.
|
// Use html5 <time> tag for valid timestamps.
|
||||||
|
|||||||
10
zerver/tests/fixtures/markdown_test_cases.json
vendored
10
zerver/tests/fixtures/markdown_test_cases.json
vendored
@@ -750,7 +750,7 @@
|
|||||||
"name": "timestamp_backend_markdown_only",
|
"name": "timestamp_backend_markdown_only",
|
||||||
"input": "<time:Jun 5th 2017, 10:30PM>",
|
"input": "<time:Jun 5th 2017, 10:30PM>",
|
||||||
"expected_output": "<p><time datetime=\"2017-06-05T22:30:00Z\">Jun 5th 2017, 10:30PM</time></p>",
|
"expected_output": "<p><time datetime=\"2017-06-05T22:30:00Z\">Jun 5th 2017, 10:30PM</time></p>",
|
||||||
"marked_expected_output": "<p><span class=\"timestamp-error\">Invalid time format: Jun 5th 2017, 10:30PM</span></p>"
|
"marked_expected_output": "<p><span>Jun 5th 2017, 10:30PM</span></p>"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "timestamp_backend_markdown_and_marked",
|
"name": "timestamp_backend_markdown_and_marked",
|
||||||
@@ -760,18 +760,20 @@
|
|||||||
{
|
{
|
||||||
"name": "timestamp_invalid_input",
|
"name": "timestamp_invalid_input",
|
||||||
"input": "<time:<alert(1)>>",
|
"input": "<time:<alert(1)>>",
|
||||||
"expected_output": "<p><span class=\"timestamp-error\">Invalid time format: <alert(1)</span>></p>"
|
"expected_output": "<p><span class=\"timestamp-error\">Invalid time format: <alert(1)</span>></p>",
|
||||||
|
"marked_expected_output": "<p><span><alert(1)</span>></p>"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "timestamp_timezone",
|
"name": "timestamp_timezone",
|
||||||
"input": "<time:31 Dec 2017 5:30 am IST>",
|
"input": "<time:31 Dec 2017 5:30 am IST>",
|
||||||
"expected_output": "<p><time datetime=\"2017-12-31T00:00:00Z\">31 Dec 2017 5:30 am IST</time></p>",
|
"expected_output": "<p><time datetime=\"2017-12-31T00:00:00Z\">31 Dec 2017 5:30 am IST</time></p>",
|
||||||
"marked_expected_output": "<p><span class=\"timestamp-error\">Invalid time format: 31 Dec 2017 5:30 am IST</span></p>"
|
"marked_expected_output": "<p><span>31 Dec 2017 5:30 am IST</span></p>"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "timestamp_incorrect",
|
"name": "timestamp_incorrect",
|
||||||
"input": "<time:**hello world**>",
|
"input": "<time:**hello world**>",
|
||||||
"expected_output": "<p><span class=\"timestamp-error\">Invalid time format: **hello world**</span></p>"
|
"expected_output": "<p><span class=\"timestamp-error\">Invalid time format: **hello world**</span></p>",
|
||||||
|
"marked_expected_output": "<p><span>**hello world**</span></p>"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "timestamp_unix",
|
"name": "timestamp_unix",
|
||||||
|
|||||||
Reference in New Issue
Block a user