diff --git a/lib/logstorage/pipe_pack_logfmt_test.go b/lib/logstorage/pipe_pack_logfmt_test.go index 57c9503c8..f138377d7 100644 --- a/lib/logstorage/pipe_pack_logfmt_test.go +++ b/lib/logstorage/pipe_pack_logfmt_test.go @@ -45,7 +45,7 @@ func TestPipePackLogfmt(t *testing.T) { }, }, [][]Field{ { - {"_msg", `_msg=x foo=abc bar="cde=ab"`}, + {"_msg", `_msg=x foo=abc bar=cde=ab`}, {"foo", `abc`}, {"bar", `cde=ab`}, }, diff --git a/lib/logstorage/rows.go b/lib/logstorage/rows.go index bee9fbd8d..9d0d77e9c 100644 --- a/lib/logstorage/rows.go +++ b/lib/logstorage/rows.go @@ -91,13 +91,25 @@ func getFieldValue(fields []Field, name string) string { func needLogfmtQuoting(s string) bool { for _, c := range s { - if !isTokenRune(c) { + if isLogfmtSpecialChar(c) { return true } } return false } +func isLogfmtSpecialChar(c rune) bool { + if c <= 0x20 { + return true + } + switch c { + case '"', '\\': + return true + default: + return false + } +} + // RenameField renames field with the oldName to newName in Fields func RenameField(fields []Field, oldName, newName string) { if oldName == "" {