copy_and_paste: Fix CSS selector injection bug.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2024-05-14 12:17:39 -07:00
committed by Tim Abbott
parent 6914d3151d
commit 2e776bf8dc

View File

@@ -425,7 +425,9 @@ export function paste_handler_converter(paste_html) {
const copied_html = new DOMParser().parseFromString(paste_html, "text/html"); const copied_html = new DOMParser().parseFromString(paste_html, "text/html");
if ( if (
!copied_html !copied_html
.querySelector("a[href='" + node.firstChild.getAttribute("href") + "']") .querySelector(
"a[href='" + CSS.escape(node.firstChild.getAttribute("href")) + "']",
)
?.parentNode?.classList.contains("message_inline_image") ?.parentNode?.classList.contains("message_inline_image")
) { ) {
// We skip previews which have their generating link copied too, to avoid // We skip previews which have their generating link copied too, to avoid