Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
compose_paste: Don't make links out of pasted linkifier syntax.
Evy Kassirerc01d7f7dff23
diff --git a/web/src/compose_paste.ts b/web/src/compose_paste.tsindex 109a4a0f28d..291d5a9d9a2 100644--- a/web/src/compose_paste.ts+++ b/web/src/compose_paste.ts@@ -397,6 +397,10 @@ export function paste_handler_converter(// ignore link's url if it only has an imagereturn content;}+ if (compose_ui.reverse_linkify_text(node.href) === content.trim()) {+ // The link text is already the linkifier syntax for its URL.+ return content;+ }return "[" + content + "](" + node.href + ")";},});diff --git a/web/tests/compose_paste.test.cjs b/web/tests/compose_paste.test.cjsindex 5b8c610ba69..898a7a82e17 100644--- a/web/tests/compose_paste.test.cjs+++ b/web/tests/compose_paste.test.cjs@@ -249,6 +249,24 @@ run_test("paste_handler reverse linkify", ({override, override_rewire}) => {expected: "#D42",expected_undo_texts: ["https://github.com/zulip/zulip-desktop/issues/42"],},+ {+ // A link whose text is already the linkifier syntax for its+ // URL should paste as plain text, not a markdown link.+ paste_html:+ 'See <a href="https://github.com/zulip/zulip-desktop/pull/1359">#D1359</a> for details.',+ paste_text: "See #D1359 for details.",+ expected: "See #D1359 for details.",+ expected_undo_texts: [],+ },+ {+ // A link whose text looks like linkifier syntax but points+ // elsewhere should keep its URL.+ paste_html:+ 'See <a href="https://github.com/zulip/zulip-desktop/pull/42">#D1359</a> for details.',+ paste_text: "See #D1359 for details.",+ expected: "See [#D1359](https://github.com/zulip/zulip-desktop/pull/42) for details.",+ expected_undo_texts: ["See #D1359 for details."],+ },];for (const test_case of test_cases) {