From 8e080e492693a522ef05c80895b04fdad0183896 Mon Sep 17 00:00:00 2001 From: flamingos-cant <45780476+flamingo-cant-draw@users.noreply.github.com> Date: Wed, 19 Mar 2025 10:56:34 +0000 Subject: [PATCH] Add backslahses to prevent image embeds breaking (#5506) * Replace newlines with spaces in attachments * Use backslash to prevent breaks instead * fmt * Split + join with spaces --- crates/apub/src/protocol/objects/page.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/apub/src/protocol/objects/page.rs b/crates/apub/src/protocol/objects/page.rs index d2f6bdb05..98194c380 100644 --- a/crates/apub/src/protocol/objects/page.rs +++ b/crates/apub/src/protocol/objects/page.rs @@ -133,6 +133,9 @@ impl Attachment { let is_image = media_type.is_some_and(|media| media.starts_with("video") || media.starts_with("image")); + // Markdown images can't have linebreaks in them, so to prevent creating + // broken image embeds, replace them with spaces + let name = name.map(|n| n.split_whitespace().collect::>().join(" ")); if is_image { let url = proxy_image_link(url, context).await?;