1
0
mirror of https://github.com/amir20/dozzle.git synced 2025-12-24 14:31:44 +01:00

fix: fixes parsing of logfmt logs with a regex. fixes #2834 (#2835)

This commit is contained in:
Amir Raminfar
2024-03-19 14:36:39 -07:00
committed by GitHub
parent 9bf6cd8821
commit 993b3fd2f6

View File

@@ -156,7 +156,8 @@ func readEvent(reader *bufio.Reader, tty bool) (string, StdType, error) {
}
}
var validLogFmtKey = regexp.MustCompile(`^[a-zA-Z0-9_]+$`)
var validLogFmtMessage = regexp.MustCompile(`([a-zA-Z0-9_.-]+)=(?:(?:"(.*)")|(?:(?:([^\s]+)[\s])))`)
var validLogFmtKey = regexp.MustCompile(`^[a-zA-Z0-9_.-]+$`)
func createEvent(message string, streamType StdType) *LogEvent {
h := fnv.New32a()
@@ -180,7 +181,7 @@ func createEvent(message string, streamType StdType) *LogEvent {
} else {
logEvent.Message = data
}
} else if strings.Contains(message, "=") {
} else if validLogFmtMessage.MatchString(message) {
buffer := bufPool.Get().(*bytes.Buffer)
buffer.Reset()
defer bufPool.Put(buffer)