Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
postprocess: Fix animated images automatically playing on Firefox.
Abel Abate2e95012c90a4
diff --git a/web/src/postprocess_content.ts b/web/src/postprocess_content.tsindex c2cafcdebfb..b5c7edaf7fe 100644--- a/web/src/postprocess_content.ts+++ b/web/src/postprocess_content.ts@@ -108,7 +108,15 @@ export function postprocess_content(html: string): string {"div.message_inline_image > a > img",)) {inline_img.setAttribute("loading", "lazy");- if (inline_img.src.startsWith("/user_uploads/thumbnail/")) {+ // We can't just check whether `inline_image.src` starts with+ // `/user_uploads/thumbnail`, even though that's what the+ // server writes in the markup, because Firefox will have+ // already prepended the origin to the source of an image.+ const image_url = new URL(inline_img.src, window.location.origin);+ if (+ image_url.origin === window.location.origin &&+ image_url.pathname.startsWith("/user_uploads/thumbnail/")+ ) {let thumbnail_name = thumbnail.preferred_format.name;if (inline_img.dataset.animated === "true") {if (