OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Fix #format_text to return HTML-safe empty strings
Alexander Brandon Colesbd9bdab7482f
diff --git a/lib/open_project/text_formatting.rb b/lib/open_project/text_formatting.rbindex 7cc2e8a98c7..c46d9ffcbfe 100644--- a/lib/open_project/text_formatting.rb+++ b/lib/open_project/text_formatting.rb@@ -90,7 +90,7 @@ module OpenProjectelseraise ArgumentError, "invalid arguments to format_text"end- return "" if text.blank?+ return "".html_safe if text.blank?project ||= @project || object.try(:project)diff --git a/spec/lib/open_project/text_formatting/text_formatting_spec.rb b/spec/lib/open_project/text_formatting/text_formatting_spec.rbindex 9a59d2cafdc..32af028e8e6 100644--- a/spec/lib/open_project/text_formatting/text_formatting_spec.rb+++ b/spec/lib/open_project/text_formatting/text_formatting_spec.rb@@ -59,6 +59,21 @@ RSpec.describe OpenProject::TextFormatting do))end+ describe "HTML safety" do+ context "with blank strings" do+ it "always returns HTML-safe strings" do+ expect(format_text("")).to be_html_safe+ expect(format_text(" ")).to be_html_safe+ end+ end++ context "with non-blank strings" do+ it "always returns HTML-safe strings" do+ expect(format_text("abc")).to be_html_safe+ end+ end+ end+describe "options" dodescribe "#format" doit "uses format of Settings, if nothing is specified" do