Class: RuboCop::Cop::Rails::OutputSafety
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Rails::OutputSafety
- Defined in:
- lib/rubocop/cop/rails/output_safety.rb
Overview
This cop checks for the use of output safety calls like ‘html_safe`, `raw`, and `safe_concat`. These methods do not escape content. They simply return a SafeBuffer containing the content as is. Instead, use `safe_join` to join content and escape it and concat to concatenate content and escape it, ensuring its safety.
Constant Summary collapse
- MSG =
'Tagging a string as html safe may be a security risk.'
Instance Method Summary collapse
- #on_send(node) ⇒ Object (also: #on_csend)
Instance Method Details
#on_send(node) ⇒ Object Also known as: on_csend
68 69 70 71 72 73 74 75 76 |
# File 'lib/rubocop/cop/rails/output_safety.rb', line 68 def on_send(node) return if non_interpolated_string?(node) return unless looks_like_rails_html_safe?(node) || looks_like_rails_raw?(node) || looks_like_rails_safe_concat?(node) add_offense(node, location: :selector) end |