Project

General

Profile

Patch #43428 » 0002-Fix-for-https-github.com-rails-rails-pull-55404.patch

Takashi Kato, 2025-11-02 02:10

View differences:

app/helpers/application_helper.rb
1570 1570
    fields_for(*args, &)
1571 1571
  end
1572 1572

  
1573
  def form_tag_html(html_options)
1574
    # Set a randomized name attribute on all form fields by default
1575
    # as a workaround to https://bugzilla.mozilla.org/show_bug.cgi?id=1279253
1576
    html_options['name'] ||= "#{html_options['id'] || 'form'}-#{SecureRandom.hex(4)}"
1577
    super
1578
  end
1579

  
1580 1573
  # Render the error messages for the given objects
1581 1574
  def error_messages_for(*objects)
1582 1575
    objects = objects.filter_map {|o| o.is_a?(String) ? instance_variable_get(:"@#{o}") : o}
config/initializers/10-patches.rb
102 102
      super
103 103
    end
104 104
  end)
105
  module Helpers
106
    # Set a randomized name attribute on all form fields by default
107
    # as a workaround to https://bugzilla.mozilla.org/show_bug.cgi?id=1279253
108
    FormHelper.prepend(Module.new do
109
      def form_tag_html(html_options)
110
        randomized_name_attribute(html_options)
111
        super
112
      end
113

  
114
      def form_tag_with_body(html_options, output)
115
        randomized_name_attribute(html_options)
116
        super
117
      end
118

  
119
      def randomized_name_attribute(html_options)
120
        html_options['name'] ||= "#{html_options['id'] || 'form'}-#{SecureRandom.hex(4)}"
121
      end
122
    end)
123
  end
105 124
end
106 125

  
107 126
module ActionController
(2-2/3)