mirror of
https://github.com/BaaRai/ARTEX.git
synced 2026-11-26 01:41:04 +08:00
The logged response body was inserted raw. A newline in that body became another log record. CR and LF are now spaces before the line is written.
17 lines
367 B
Go
17 lines
367 B
Go
package agent
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestClipBodyFlattensNewlines(t *testing.T) {
|
|
got := clipBody("ok\r\ninjected log line\n")
|
|
if strings.Contains(got, "\n") || strings.Contains(got, "\r") {
|
|
t.Fatalf("clipBody kept a line break: %q", got)
|
|
}
|
|
if !strings.Contains(got, "injected log line") {
|
|
t.Fatalf("clipBody dropped the text: %q", got)
|
|
}
|
|
}
|