Skip to content

Commit 860f23c

Browse files
committed
Merge pull request rails#52108 from fresh-eggs/7-2-stable
[`7-2-stable` Backport] Fix action-text-attachment HTML escaping regression test
1 parent 2ebb508 commit 860f23c

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

actiontext/test/unit/attachment_test.rb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,10 @@ class ActionText::AttachmentTest < ActiveSupport::TestCase
7979
end
8080
end
8181

82-
test "sanitizes HTML content attachment" do
83-
attachment = attachment_from_html('<action-text-attachment content-type="text/html" content="<img src=\&quot;.\&quot; onerror=alert>"></action-text-attachment>')
84-
attachable = attachment.attachable
82+
test "to_trix_html sanitizes action-text HTML content attachment" do
83+
attachment = ActionText::Content.new("<action-text-attachment content-type=\"text/html\" content=\"<img src=. onerror='alert(location)' />\"></action-text-attachment>")
8584

86-
ActionText::Content.with_renderer MessagesController.renderer do
87-
assert_equal "<img src=\"\\%22.\\%22\">", attachable.to_html.strip
88-
end
85+
assert_equal "<figure data-trix-attachment=\"{&quot;contentType&quot;:&quot;text/html&quot;,&quot;content&quot;:&quot;<img src=\\&quot;.\\&quot;>&quot;}\"></figure>", attachment.to_trix_html
8986
end
9087

9188
test "defaults trix partial to model partial" do

0 commit comments

Comments
 (0)