From b0a9ed9fc2f8eb2c27781d2d6430c7cf20cfa570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Storfjord=20Kristiansen?= <33384479+dev-bio@users.noreply.github.com> Date: Thu, 1 Aug 2024 17:14:26 +0200 Subject: [PATCH] Perform some cleaning operations on line breaks. Co-authored-by: Jintao Zhang --- internal/ingress/controller/template/template.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/internal/ingress/controller/template/template.go b/internal/ingress/controller/template/template.go index c70406cf02..8628f80903 100644 --- a/internal/ingress/controller/template/template.go +++ b/internal/ingress/controller/template/template.go @@ -136,6 +136,13 @@ func cleanConf(in, out *bytes.Buffer) error { case ' ', '\t': needOutput = lineStarted case '\r': + rest := in.Bytes() + if len(rest) > 0 { + if rest[0] != '\n' { + c = ' ' + needOutput = lineStarted + } + } case '\n': needOutput = !(!lineStarted && emptyLineWritten) nextLineStarted = false @@ -150,6 +157,13 @@ func cleanConf(in, out *bytes.Buffer) error { case stateComment: switch c { case '\r': + rest := in.Bytes() + if len(rest) > 0 { + if rest[0] != '\n' { + c = ' ' + needOutput = lineStarted + } + } case '\n': needOutput = true nextLineStarted = false