Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Action Text sanitizer initialization #48753

Conversation

flavorjones
Copy link
Member

Motivation / Background

Using initializer in the engine may run the block before application initializers. Instead, use config.after_initialize to ensure that application initializers take effect properly.

Also, don't bother deleting the config value, since that pattern isn't needed here (as it is in other railties like action_view/railtie.rb).

See similar fix for Action View in #48747.

Detail

Replace initializer with config.after_initialize.

Additional information

I'm not sure how to test this behavior properly other than to set up an application and run the code. I would love to learn how to better test initializer order.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

Using `initializer` in the engine may run the block before application
initializers. Instead, use `config.after_initialize` to ensure that
application initializers take effect properly.

Also, don't bother deleting the config value, since that pattern isn't
needed here (as it is in other railties like action_view/railtie.rb).
@rails-bot rails-bot bot added the actiontext label Jul 17, 2023
@eileencodes eileencodes merged commit 99f8b04 into rails:main Jul 17, 2023
9 checks passed
flavorjones referenced this pull request Jul 17, 2023
Rails 7.1 defaults to Rails::HTML::Sanitizer.best_supported_vendor,
earlier configs will use Rails::HTML4::Sanitizer.

Related to #48523 / 55bca6b.
@flavorjones flavorjones deleted the flavorjones-fix-action-text-sanitizer-initializer branch August 3, 2023 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants