1
0
mirror of https://github.com/meineerde/redmine.git synced 2025-12-20 15:31:12 +00:00

Add a randomized name attribute to all form fields (#26604).

This is a workaround for a Bug in Firefox described at
https://bugzilla.mozilla.org/show_bug.cgi?id=1279253

Patch by Holger Just.

git-svn-id: http://svn.redmine.org/redmine/trunk@18306 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2019-06-20 16:46:10 +00:00
parent a59e33acef
commit 1cc269967a
2 changed files with 16 additions and 0 deletions

View File

@ -1306,6 +1306,13 @@ module ApplicationHelper
fields_for(*args, &proc) fields_for(*args, &proc)
end end
def form_tag_html(html_options)
# Set a randomized name attribute on all form fields by default
# as a workaround to https://bugzilla.mozilla.org/show_bug.cgi?id=1279253
html_options['name'] ||= "#{html_options['id'] || 'form'}-#{SecureRandom.hex(4)}"
super
end
# Render the error messages for the given objects # Render the error messages for the given objects
def error_messages_for(*objects) def error_messages_for(*objects)
objects = objects.map {|o| o.is_a?(String) ? instance_variable_get("@#{o}") : o}.compact objects = objects.map {|o| o.is_a?(String) ? instance_variable_get("@#{o}") : o}.compact

View File

@ -1807,6 +1807,15 @@ RAW
assert_equal '<span class="hours hours-int">0</span><span class="hours hours-dec">.75</span>', html_hours('0.75') assert_equal '<span class="hours hours-int">0</span><span class="hours hours-dec">.75</span>', html_hours('0.75')
end end
def test_form_for_includes_name_attribute
assert_match(/name="new_issue-[a-z0-9]{8}"/, form_for(Issue.new){})
end
def test_labelled_form_for_includes_name_attribute
assert_match(/name="new_issue-[a-z0-9]{8}"/, labelled_form_for(Issue.new){})
end
private private
def wiki_links_with_special_characters def wiki_links_with_special_characters