Fix render_flash_messages method to ignore non-string flash values and prevent errors (#42073).

Patch by Katsuya HIDAKA (user:hidakatsuya).


git-svn-id: https://svn.redmine.org/redmine/trunk@23821 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2025-06-06 06:34:26 +00:00
parent 6824ee98f4
commit 8c10cf3f30
2 changed files with 10 additions and 0 deletions

View File

@@ -518,6 +518,8 @@ module ApplicationHelper
def render_flash_messages
s = +''
flash.each do |k, v|
next unless v.is_a?(String)
s << content_tag('div', notice_icon(k) + v.html_safe, :class => "flash #{k}", :id => "flash_#{k}")
end
s.html_safe

View File

@@ -2403,6 +2403,14 @@ class ApplicationHelperTest < Redmine::HelperTest
assert_equal expected, format_activity_description(text)
end
def test_render_flash_messages_should_ignore_non_string_values
flash[:array_value] = ['1', '2']
flash[:hash_value] = { foo: 'bar' }
result = render_flash_messages
assert_equal '', result
end
private
def wiki_links_with_special_characters