From 0ed6cf17750b887c0bf06253a52a0cfac8db7256 Mon Sep 17 00:00:00 2001 From: trichoplax Date: Fri, 31 Jul 2026 06:54:11 +0100 Subject: [PATCH 1/2] Ignore CRLF line ending changes in diffs --- app/views/post_history/_diff.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/post_history/_diff.html.erb b/app/views/post_history/_diff.html.erb index e63be8418..77eb63d7b 100644 --- a/app/views/post_history/_diff.html.erb +++ b/app/views/post_history/_diff.html.erb @@ -1,7 +1,7 @@
<% if before.present? && after.present? %> <% if before.is_a?(String) && after.is_a?(String) %> - <% diff = Diffy::SplitDiff.new(before, after, format: :html) %> + <% diff = Diffy::SplitDiff.new(before, after, format: :html, ignore_crlf: true) %>
<%= raw(diff.left) %> @@ -78,4 +78,4 @@ <% end %>
<% end %> -
\ No newline at end of file +
From 6ebeec0ca95f50fa6f0a9f63dac5d99cda5c5234 Mon Sep 17 00:00:00 2001 From: trichoplax Date: Fri, 31 Jul 2026 07:12:48 +0100 Subject: [PATCH 2/2] Normalize newlines in diff before_state and after_state --- app/models/concerns/post_validations.rb | 4 ++-- app/models/post_history.rb | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/models/concerns/post_validations.rb b/app/models/concerns/post_validations.rb index 9b8fa745a..1deaa0e51 100644 --- a/app/models/concerns/post_validations.rb +++ b/app/models/concerns/post_validations.rb @@ -3,8 +3,8 @@ module PostValidations extend ActiveSupport::Concern included do - normalizes :body_markdown, with: lambda { |body_markdown| - body_markdown.encode(body_markdown.encoding, universal_newline: true) + normalizes :body_markdown, with: lambda { |text| + text.encode(text.encoding, universal_newline: true) } validate :tags_in_tag_set, if: -> { post_type.has_tags } diff --git a/app/models/post_history.rb b/app/models/post_history.rb index 4e1fdfd6b..2190ac642 100644 --- a/app/models/post_history.rb +++ b/app/models/post_history.rb @@ -11,6 +11,12 @@ class PostHistory < ApplicationRecord scope :of_type, ->(name) { joins(:post_history_type).where(post_history_types: { name: name }) } scope :on_undeleted, -> { joins(:post).where(posts: { deleted: false }) } + normalize_newlines = lambda { |text| + text.encode(text.encoding, universal_newline: true) + } + normalizes :before_state, with: normalize_newlines + normalizes :after_state, with: normalize_newlines + def before_tags tags.where(post_history_tags: { relationship: 'before' }) end