Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

copy_and_paste: Fix CSS selector injection bug.

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