Save 36% for Black Friday! Save 36% on GoRails for Black Friday! Learn more
matt swanson
Joined
Activity
Can move the code to config.after_initialize
or inside ActiveSupport.on_load(:action_text_content)
Switching config.load_defaults
to 7.1
switches from Rails::HTML4::SafeListSanitizer to the new Rails::HTML5::SafeListSanitizer which doesn't seem to pickup these changes in the initializer
Thanks, that worked. I added this test to my project to verify and handle any future changes
require "test_helper"
class ActionTextCustomizationTest < ActiveSupport::TestCase
test 'action text links should have rel="noopener noreferrer" and target="_blank"' do
text = ActionText::RichText.new(
body: "<a href='https://example.com'>Example</a>"
)
assert_includes text.to_s, "rel=\"noopener noreferrer\""
assert_includes text.to_s, "target=\"_blank\""
end
end
ActionText::ContentHelper.allowed_attributes dont seem to be working in Rails 7.1 due to some changes to the sanitizer
Hey! Sorry this is probably too late to help in your case but you can override the: attachable_plain_text_representation(caption)
method on your ActionText::Attachable model. By default this method uses the caption
(for images) but since we aren't setting a caption for @-mentions, the text is blank if you call to_plain_text
.
In this example, you might override the method to return something like "@#{name}" for the plain text formatting.