fix: do not treat consecutive groups of 3 dashes in a line as document separators

Signed-off-by: Marvin Rösch <marvinroesch99@gmail.com>
pull/31936/head
Marvin Rösch 7 months ago
parent d3df72e560
commit 506a93a6b3
No known key found for this signature in database
GPG Key ID: 25FA8AEEE65B8E5F

@ -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])

@ -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",

Loading…
Cancel
Save