diff options
author | Go MAEDA <maeda@farend.jp> | 2025-06-06 06:34:26 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2025-06-06 06:34:26 +0000 |
commit | 8c10cf3f30bed241bf23953bbbc43c419a8065fb (patch) | |
tree | 46d57adedba8795d190e347d592cd690ecc6b8dd | |
parent | 6824ee98f4df5fc777fb3bf8dcb1abf570dd8023 (diff) | |
download | redmine-8c10cf3f30bed241bf23953bbbc43c419a8065fb.tar.gz redmine-8c10cf3f30bed241bf23953bbbc43c419a8065fb.zip |
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
-rw-r--r-- | app/helpers/application_helper.rb | 2 | ||||
-rw-r--r-- | test/helpers/application_helper_test.rb | 8 |
2 files changed, 10 insertions, 0 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 99a760c1d..285528422 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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 diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb index c9ec72467..2e2e8b933 100644 --- a/test/helpers/application_helper_test.rb +++ b/test/helpers/application_helper_test.rb @@ -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 |