mirror of
https://github.com/amir20/dozzle.git
synced 2025-12-30 17:47:28 +01:00
fix: fixes log parser (#3398)
This commit is contained in:
@@ -17,7 +17,7 @@ func ParseLogFmt(log string) (*orderedmap.OrderedMap[string, string], error) {
|
||||
char := log[i]
|
||||
if isKey {
|
||||
if char == '=' {
|
||||
if i == start {
|
||||
if start >= i {
|
||||
return nil, errors.New("invalid format: key is empty")
|
||||
}
|
||||
key = log[start:i]
|
||||
|
||||
@@ -67,6 +67,12 @@ func TestParseLog(t *testing.T) {
|
||||
),
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "Broken format with unexpected quotes",
|
||||
log: `key1=value"1"= key2="value2"`,
|
||||
want: nil,
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "Invalid log with unclosed quotes",
|
||||
log: "key1=\"value1 key2=value2",
|
||||
|
||||
Reference in New Issue
Block a user