From c102e0b93044ad9d274b9eae335190c3b10ae971 Mon Sep 17 00:00:00 2001 From: Jintao Zhang Date: Fri, 2 Aug 2024 21:37:45 +0800 Subject: [PATCH] Perform some cleaning operations on line breaks. (#11720) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: André Storfjord Kristiansen <33384479+dev-bio@users.noreply.github.com> --- 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 c70406cf0..8628f8090 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