diff --git a/xwiki-platform-core/xwiki-platform-flamingo/xwiki-platform-flamingo-skin/xwiki-platform-flamingo-skin-test/xwiki-platform-flamingo-skin-test-docker/src/test/it/org/xwiki/flamingo/test/docker/EditIT.java b/xwiki-platform-core/xwiki-platform-flamingo/xwiki-platform-flamingo-skin/xwiki-platform-flamingo-skin-test/xwiki-platform-flamingo-skin-test-docker/src/test/it/org/xwiki/flamingo/test/docker/EditIT.java
index ff658922b7e0..81d96f31bffb 100644
--- a/xwiki-platform-core/xwiki-platform-flamingo/xwiki-platform-flamingo-skin/xwiki-platform-flamingo-skin-test/xwiki-platform-flamingo-skin-test-docker/src/test/it/org/xwiki/flamingo/test/docker/EditIT.java
+++ b/xwiki-platform-core/xwiki-platform-flamingo/xwiki-platform-flamingo-skin/xwiki-platform-flamingo-skin-test/xwiki-platform-flamingo-skin-test-docker/src/test/it/org/xwiki/flamingo/test/docker/EditIT.java
@@ -677,7 +677,7 @@ public void editWithConflict(TestUtils setup, TestReference testReference)
wikiEditPageTab1.setContent(
"First line."
- + "\nSecond line."
+ + "\n"
+ "\nLine N°4"
+ "\nFifth line."
+ "\n6th line."
@@ -690,9 +690,9 @@ public void editWithConflict(TestUtils setup, TestReference testReference)
assertEquals(EditConflictModal.ConflictChoice.MERGE, editConflictModal.getCurrentChoice());
assertEquals(Arrays.asList("@@ -1,6 +1,6 @@",
" First line.",
- "-Line N°2",
+ "-Line N°2",
"-Third line.",
- "+Second line.",
+ "+<script>alert('Second line.')</script>",
"+Line N°4",
" Fifth line.",
"-Sixth line.",
@@ -705,9 +705,9 @@ public void editWithConflict(TestUtils setup, TestReference testReference)
assertEquals(Arrays.asList("@@ -1,1 +1,1 @@",
" First line.",
"@@ -2,2 +2,2 @@",
- "-Line N°2",
+ "-Line N°2",
"-Third line.",
- "+Second line.",
+ "+<script>alert('Second line.')</script>",
"+Line N°4",
"[Conflict Resolution]",
"@@ -4,1 +4,1 @@",
@@ -727,7 +727,7 @@ public void editWithConflict(TestUtils setup, TestReference testReference)
assertEquals(Conflict.DecisionType.CURRENT, conflict.getCurrentDecision());
assertFalse(conflict.isDecisionChangeEmpty());
- assertEquals("Second line.\nLine N°4", conflict.getDecisionChange());
+ assertEquals("\nLine N°4", conflict.getDecisionChange());
conflict.setDecision(Conflict.DecisionType.PREVIOUS);
assertFalse(conflict.isDecisionChangeEmpty());
assertEquals("Second line.\nThird line.", conflict.getDecisionChange());
diff --git a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/diff_macros.vm b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/diff_macros.vm
index 1807bf736da5..dc437735e24e 100644
--- a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/diff_macros.vm
+++ b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/diff_macros.vm
@@ -82,7 +82,16 @@
#else
#set ($spanClass = "diff-decision")
#end
- $stringtool.join($value, "
")
+
+## We do not want the renderer to add any extra spaces or linebreaks in this output.
+#* *###
+#* *##foreach ($v in $value)
+#* *#$escapetool.xml($v)##
+#* *##if ($foreach.hasNext)
+#* *#
##
+#* *##end
+#* *##end
+#* *#
#end
#macro (displayPropertyDiff $propertyName $previousValue $newValue $_obfuscate $conflicts $realPropertyName)