require "test_helper" class ActionTextRenderingTest < ActionView::TestCase test "data-action attributes in user content are stripped" do malicious_html = <<~HTML

Click here: malicious link

HTML content = ActionText::Content.new(malicious_html) rendered = content.to_s assert_no_match(/data-action/, rendered) assert_match(/malicious link<\/a>/, rendered) end end