Gracefully handle ill-formed remote images in rich text

A better fix has been proposed upstream at
https://github.com/rails/rails/pull/56283 but this should be fine in
the meantime.

ref: https://app.fizzy.do/5986089/cards/3188
This commit is contained in:
Mike Dalessio
2025-12-03 11:24:39 -05:00
parent 069e0ca0b2
commit 89940d36f8
3 changed files with 13 additions and 2 deletions
@@ -1,5 +1,5 @@
<figure class="attachment attachment--preview">
<%= image_tag remote_image.url, width: remote_image.width, height: remote_image.height %>
<%= image_tag remote_image.url, skip_pipeline: true, width: remote_image.width, height: remote_image.height %>
<% if caption = remote_image.try(:caption) %>
<figcaption class="attachment__caption">
<%= caption %>
@@ -1 +1 @@
<%= image_tag remote_image.url, class: "attachment attachment--image", width: remote_image.width, height: remote_image.height %>
<%= image_tag remote_image.url, skip_pipeline: true, class: "attachment attachment--image", width: remote_image.width, height: remote_image.height %>
+11
View File
@@ -121,4 +121,15 @@ class CardsControllerTest < ActionDispatch::IntegrationTest
assert_redirected_to boards(:writebook)
end
test "show card with comment containing malformed remote image attachment" do
card = cards(:logo)
card.comments.create!(
creator: users(:kevin),
body: '<action-text-attachment url="image.png" content-type="image/*" presentation="gallery"></action-text-attachment>'
)
get card_path(card)
assert_response :success
end
end