From dbd3d55fa7f0ea3636211b85ecb69c5895ca7677 Mon Sep 17 00:00:00 2001 From: Brandt Keller Date: Sat, 28 Mar 2026 09:46:22 -0700 Subject: [PATCH] fix(action): block scalar supprot for contiguous separators Signed-off-by: Brandt Keller --- pkg/action/action.go | 11 +++++++++-- pkg/action/action_test.go | 5 +++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/pkg/action/action.go b/pkg/action/action.go index 75b6cf8a0..68311b254 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -162,8 +162,15 @@ 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 past all contiguous dashes to avoid re-examining + // interior dashes of a long sequence (e.g. "--------------------") + // as a new "---" at position 0 of the remaining buffer. + end := idx + 3 + for end < len(remaining) && remaining[end] == '-' { + end++ + } + b.WriteString(remaining[:end]) + remaining = remaining[end:] continue } b.WriteString(remaining[:idx+3]) diff --git a/pkg/action/action_test.go b/pkg/action/action_test.go index 62e8adfea..fd0120d90 100644 --- a/pkg/action/action_test.go +++ b/pkg/action/action_test.go @@ -484,6 +484,11 @@ func TestFixDocSeparators(t *testing.T) { input: "----more\napiVersion: v1\n", expected: "---\n-more\napiVersion: v1\n", }, + { + name: "long dashes in block scalar are not separators", + input: "apiVersion: v1\nkind: Job\nspec:\n containers:\n - command:\n - |\n echo --------------------\n echo done\n", + expected: "apiVersion: v1\nkind: Job\nspec:\n containers:\n - command:\n - |\n echo --------------------\n echo done\n", + }, } for _, tt := range tests {