Class: PlatformosCheck::FormAction

Inherits:
HtmlCheck show all
Defined in:
lib/platformos_check/checks/form_action.rb

Constant Summary collapse

VALID_ACTION_START =
['/', '{%', '{{', '#', 'http'].freeze

Constants inherited from HtmlCheck

HtmlCheck::START_OR_END_QUOTE

Constants inherited from Check

Check::CATEGORIES, Check::SEVERITIES, Check::SEVERITY_VALUES

Instance Attribute Summary

Attributes inherited from Check

#ignored_patterns, #offenses, #options, #platformos_app

Instance Method Summary collapse

Methods included from ChecksTracking

#inherited

Methods inherited from Check

#==, #add_offense, all, can_disable, #can_disable?, categories, #categories, category, #code_name, doc, #doc, docs_url, #ignore!, #ignored?, #severity, severity, #severity=, #severity_value, severity_value, single_file, #single_file?, #to_s, #whole_platformos_app?

Methods included from JsonHelpers

#format_json_parse_error, #pretty_json

Instance Method Details

#on_form(node) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/platformos_check/checks/form_action.rb', line 11

def on_form(node)
  action = node.attributes["action"]&.strip
  return if action.nil?
  return if action.empty?
  return if action.start_with?(*VALID_ACTION_START)

  add_offense("Use action=\"/#{action}\" (start with /) to ensure the form can be submitted multiple times in case of validation errors", node:)
end