From 2fc7a6ec45baf2309ad1d6cc40e6fd447e7bd2c3 Mon Sep 17 00:00:00 2001 From: k8s-infra-cherrypick-robot <90416843+k8s-infra-cherrypick-robot@users.noreply.github.com> Date: Fri, 2 Aug 2024 08:09:20 -0700 Subject: [PATCH] Perform some cleaning operations on line breaks. (#11721) 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> 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 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