From 506a93a6b3dd955fcc385409e763a0159c177cc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20R=C3=B6sch?= Date: Fri, 13 Mar 2026 08:40:55 +0100 Subject: [PATCH] fix: do not treat consecutive groups of 3 dashes in a line as document separators MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marvin Rösch --- pkg/action/action.go | 9 +++++++-- pkg/action/action_test.go | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/action/action.go b/pkg/action/action.go index 75b6cf8a0..06bdd2468 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -162,8 +162,13 @@ func fixDocSeparators(content string) string { } // "---" must be at the start of a line: either idx==0 or preceded by '\n'. if idx > 0 && remaining[idx-1] != '\n' { - b.WriteString(remaining[:idx+3]) - remaining = remaining[idx+3:] + // Skip all remaining dashes in the line, otherwise they'll be considered as at the start of a line + nonDashIndex := idx + 3 + for nonDashIndex < len(remaining) && remaining[nonDashIndex] == '-' { + nonDashIndex++ + } + b.WriteString(remaining[:nonDashIndex]) + remaining = remaining[nonDashIndex:] continue } b.WriteString(remaining[:idx+3]) diff --git a/pkg/action/action_test.go b/pkg/action/action_test.go index 5271e34fa..d3adf0a45 100644 --- a/pkg/action/action_test.go +++ b/pkg/action/action_test.go @@ -454,6 +454,11 @@ func TestFixDocSeparators(t *testing.T) { input: "data:\n key: ---value\n", expected: "data:\n key: ---value\n", }, + { + name: "multiple triple dashes in a value is not a separator", + input: "data:\n key: ---------value\n", + expected: "data:\n key: ---------value\n", + }, { name: "realistic multi-doc template output", input: "apiVersion: v1\nkind: Deployment\n---\napiVersion: v1\nkind: Ingress\n---apiVersion: v1\nkind: Service\n",