You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's being used to generate HTML looking like this:
Expected
I would expect that this works flawlessly, because Rails uses the convention to treat i18n keys ending with _html as safe.
Actual
But actually Rubocop complains:
app/helpers/user_helper.rb:26:63: C: Rails/OutputSafety: Tagging a string as html safe may be a security risk.
target: '_blank', rel: 'noopener')).html_safe
^^^^^^^^^
Workaround
In the past we used sanitize to work around this problem, but that's not the right measure in my eyes. All generated HTML code in this example is framework-owned. Why should I not be able to mark it as safe?
I've got a helper method:
It's being used to generate HTML looking like this:
Expected
I would expect that this works flawlessly, because Rails uses the convention to treat i18n keys ending with
_html
as safe.Actual
But actually Rubocop complains:
Workaround
In the past we used
sanitize
to work around this problem, but that's not the right measure in my eyes. All generated HTML code in this example is framework-owned. Why should I not be able to mark it as safe?RuboCop version
The text was updated successfully, but these errors were encountered: