From 7623128a6dab5302cff295385e70346a18b9977f Mon Sep 17 00:00:00 2001 From: nikitafine Date: Sun, 4 Sep 2022 19:56:46 +0400 Subject: [PATCH] '\n\r' fix clrf --- environment/docker/container.go | 2 +- system/utils.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/environment/docker/container.go b/environment/docker/container.go index 6973e78b..4cbdf219 100644 --- a/environment/docker/container.go +++ b/environment/docker/container.go @@ -284,7 +284,7 @@ func (e *Environment) SendCommand(c string) error { e.SetState(environment.ProcessStoppingState) } - _, err := e.stream.Conn.Write([]byte(c + "\n")) + _, err := e.stream.Conn.Write([]byte(c + "\r")) return errors.Wrap(err, "environment/docker: could not write to container stream") } diff --git a/system/utils.go b/system/utils.go index 31b63ca1..54176777 100644 --- a/system/utils.go +++ b/system/utils.go @@ -14,6 +14,7 @@ import ( var ( cr = []byte(" \r") + lf = []byte(" \n") crr = []byte("\r\n") ) @@ -70,7 +71,9 @@ func ScanReader(r io.Reader, callback func(line []byte)) error { // in line with that it thinks is the terminal size. Those returns break a lot of output handling, // so we'll just replace them with proper new-lines and then split it later and send each line as // its own event in the response. - line = bytes.Replace(line, cr, crr, -1) + + line = bytes.Replace(line, cr, lf, -1) + line = bytes.Replace(line, lf, crr, -1) ns := buf.Len() + len(line) // If the length of the line value and the current value in the buffer will