mirror of https://github.com/zulip/zulip.git
markdown: Fix flickering of embedded link inside Italic.
This commit fixes a bug in marked.js which caused it to double-escape
HTML when rendering messages of the form: *[text](url)*.
This fixes a bug introduced in
3bdc8bbaa5
, where an unnecessary
escape() call was added for the <em> code path, likely just because it
was adjacent to the others that needed it in the file.
Fix this, and add tests to verify that things are still being escaped
once after removing this extra escape.
Fixes #14845.
This commit is contained in:
parent
5da4332620
commit
806c1a0b8b
|
@ -1087,7 +1087,6 @@ Renderer.prototype.strong = function(text) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Renderer.prototype.em = function(text) {
|
Renderer.prototype.em = function(text) {
|
||||||
text = escape(text);
|
|
||||||
return '<em>' + text + '</em>';
|
return '<em>' + text + '</em>';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -910,6 +910,28 @@
|
||||||
"expected_output": "<div class=\"spoiler-block\"><div class=\"spoiler-header\">\n<p>header</p>\n</div><div class=\"spoiler-content\" aria-hidden=\"true\">\n<p>Content <a href=\"http://example.com/image.png\">http://example.com/image.png</a></p>\n<div class=\"message_inline_image\"><a href=\"http://example.com/image.png\"><img data-src-fullsize=\"/thumbnail?url=http%3A%2F%2Fexample.com%2Fimage.png&size=full\" src=\"/thumbnail?url=http%3A%2F%2Fexample.com%2Fimage.png&size=thumbnail\"></a></div></div></div>",
|
"expected_output": "<div class=\"spoiler-block\"><div class=\"spoiler-header\">\n<p>header</p>\n</div><div class=\"spoiler-content\" aria-hidden=\"true\">\n<p>Content <a href=\"http://example.com/image.png\">http://example.com/image.png</a></p>\n<div class=\"message_inline_image\"><a href=\"http://example.com/image.png\"><img data-src-fullsize=\"/thumbnail?url=http%3A%2F%2Fexample.com%2Fimage.png&size=full\" src=\"/thumbnail?url=http%3A%2F%2Fexample.com%2Fimage.png&size=thumbnail\"></a></div></div></div>",
|
||||||
"marked_expected_output": "<div class=\"spoiler-block\"><div class=\"spoiler-header\">\n<p>header</p>\n</div><div class=\"spoiler-content\" aria-hidden=\"true\">\n<p>Content <a href=\"http://example.com/image.png\">http://example.com/image.png</a></p>\n</div></div>",
|
"marked_expected_output": "<div class=\"spoiler-block\"><div class=\"spoiler-header\">\n<p>header</p>\n</div><div class=\"spoiler-content\" aria-hidden=\"true\">\n<p>Content <a href=\"http://example.com/image.png\">http://example.com/image.png</a></p>\n</div></div>",
|
||||||
"text_content": "header (…)\n"
|
"text_content": "header (…)\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "embedded_link_inside_Bold",
|
||||||
|
"input": "**[Static types in Python](https://blog.zulip.com/2016/10/13/static-types-in-python-oh-mypy)**",
|
||||||
|
"expected_output": "<p><strong><a href=\"https://blog.zulip.com/2016/10/13/static-types-in-python-oh-mypy\">Static types in Python</a></strong></p>"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "embedded_link_inside_Italic",
|
||||||
|
"input": "*[Static types in Python](https://blog.zulip.com/2016/10/13/static-types-in-python-oh-mypy)*",
|
||||||
|
"expected_output": "<p><em><a href=\"https://blog.zulip.com/2016/10/13/static-types-in-python-oh-mypy\">Static types in Python</a></em></p>"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "edge_case_embedded_link_inside_Bold",
|
||||||
|
"input": "<h1>**<h1>[<h2>Static types in Python</h2>](https://blog.zulip.com/2016/10/13/static-types-in-python-oh-mypy)</h1>**</h1>",
|
||||||
|
"expected_output": "<p><h1><strong><h1><a href=\"https://blog.zulip.com/2016/10/13/static-types-in-python-oh-mypy\"><h2>Static types in Python</h2></a></h1></strong></h1></p>",
|
||||||
|
"marked_expected_output": "<p><h1><strong><h1><a href=\"https://blog.zulip.com/2016/10/13/static-types-in-python-oh-mypy\"><h2>Static types in Python</h2></a></h1></strong></h1>\n\n</p>"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "edge_case_embedded_link_inside_Italic",
|
||||||
|
"input": "<h1>*<h1>[<h2>Static types in Python</h2>](https://blog.zulip.com/2016/10/13/static-types-in-python-oh-mypy)</h1>*</h1>",
|
||||||
|
"expected_output": "<p><h1><em><h1><a href=\"https://blog.zulip.com/2016/10/13/static-types-in-python-oh-mypy\"><h2>Static types in Python</h2></a></h1></em></h1></p>",
|
||||||
|
"marked_expected_output": "<p><h1><em><h1><a href=\"https://blog.zulip.com/2016/10/13/static-types-in-python-oh-mypy\"><h2>Static types in Python</h2></a></h1></em></h1>\n\n</p>"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"linkify_tests": [
|
"linkify_tests": [
|
||||||
|
|
Loading…
Reference in New Issue