Skip to content

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

[55263] Fix layout issues when diffing wiki pages

Nicolas Salgueroa41cddc4037c
diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb
index afbcb3eb10e..8ec4252105c 100644
--- a/app/controllers/wiki_controller.rb
+++ b/app/controllers/wiki_controller.rb
@@ -265,6 +265,9 @@ class WikiController < ApplicationController
helpers.format_text(@diff.content_from.data.text, disable_macro_expansion: true),
helpers.format_text(@diff.content_to.data.text, disable_macro_expansion: true)
).build
+ .gsub(/<ins class="diff(ins|mod)">\n\r?<\/ins>/, '')
+ .gsub(/<del class="diff(del|mod)">\n\r?<\/del>/, '')
+ .gsub(/^<figure class="op-uc-figure">(<figure class="table op-uc-figure_align-center op-uc-figure">)/, '\1')
else
render_404
end
diff --git a/app/helpers/wiki_helper.rb b/app/helpers/wiki_helper.rb
index ee894ddfd82..145641dc58d 100644
--- a/app/helpers/wiki_helper.rb
+++ b/app/helpers/wiki_helper.rb
@@ -58,10 +58,6 @@ module WikiHelper
breadcrumb_paths(*paths)
end
- def nl2br(content)
- content.gsub(/(?:\n\r?|\r\n?)/, "<br />").html_safe
- end
-
private
def wiki_page_options_for_select_of_level(pages,
diff --git a/app/views/wiki/diff.html.erb b/app/views/wiki/diff.html.erb
index 0ad474ed572..7972c5ca2b2 100644
--- a/app/views/wiki/diff.html.erb
+++ b/app/views/wiki/diff.html.erb
@@ -44,5 +44,5 @@ See COPYRIGHT and LICENSE files for more details.
<em>(<%= @diff.content_to.user ? link_to_user(@diff.content_to.user) : t(:label_user_anonymous) %>, <%= format_time(@diff.content_to.created_at) %>)</em>
</p>
<div class="text-diff">
- <%= nl2br @html_diff %>
+ <%= @html_diff.html_safe %>
</div>