Skip to content

Commit 89940d3

Browse files
committed
Gracefully handle ill-formed remote images in rich text
A better fix has been proposed upstream at rails/rails#56283 but this should be fine in the meantime. ref: https://app.fizzy.do/5986089/cards/3188
1 parent 069e0ca commit 89940d3

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

app/views/action_text/attachables/_remote_image.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<figure class="attachment attachment--preview">
2-
<%= image_tag remote_image.url, width: remote_image.width, height: remote_image.height %>
2+
<%= image_tag remote_image.url, skip_pipeline: true, width: remote_image.width, height: remote_image.height %>
33
<% if caption = remote_image.try(:caption) %>
44
<figcaption class="attachment__caption">
55
<%= caption %>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<%= image_tag remote_image.url, class: "attachment attachment--image", width: remote_image.width, height: remote_image.height %>
1+
<%= image_tag remote_image.url, skip_pipeline: true, class: "attachment attachment--image", width: remote_image.width, height: remote_image.height %>

test/controllers/cards_controller_test.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,15 @@ class CardsControllerTest < ActionDispatch::IntegrationTest
121121

122122
assert_redirected_to boards(:writebook)
123123
end
124+
125+
test "show card with comment containing malformed remote image attachment" do
126+
card = cards(:logo)
127+
card.comments.create!(
128+
creator: users(:kevin),
129+
body: '<action-text-attachment url="image.png" content-type="image/*" presentation="gallery"></action-text-attachment>'
130+
)
131+
132+
get card_path(card)
133+
assert_response :success
134+
end
124135
end

0 commit comments

Comments
 (0)