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
This commit is contained in:
flamingos-cant 2025-03-19 10:56:34 +00:00 committed by GitHub
parent d517f16e2c
commit 8e080e4926
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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::<Vec<_>>().join(" "));
if is_image {
let url = proxy_image_link(url, context).await?;