diff --git a/pkg/textparse/lex.l b/pkg/textparse/lex.l index 50d5390a7..f0342d4d9 100644 --- a/pkg/textparse/lex.l +++ b/pkg/textparse/lex.l @@ -81,9 +81,9 @@ M [a-zA-Z_:] {S}({L}|{D})*= s = lstateLValue l.offsets = append(l.offsets, l.i-1) -\"(\\.|[^\\"])*\" s = lstateLabels +\"(\\.|[^\\"]|\0)*\" s = lstateLabels l.offsets = append(l.offsets, l.i-1) -\'(\\.|[^\\'])*\' s = lstateLabels +\'(\\.|[^\\']|\0)*\' s = lstateLabels l.offsets = append(l.offsets, l.i-1) [ \t]+ l.vstart = l.i diff --git a/pkg/textparse/lex.l.go b/pkg/textparse/lex.l.go index d28a0248a..4742c20d8 100644 --- a/pkg/textparse/lex.l.go +++ b/pkg/textparse/lex.l.go @@ -318,13 +318,11 @@ yystate27: c = l.next() switch { default: - goto yyabort + goto yystate27 // c >= '\x00' && c <= '!' || c >= '#' && c <= '[' || c >= ']' && c <= 'ÿ' case c == '"': goto yystate28 case c == '\\': goto yystate29 - case c >= '\x01' && c <= '!' || c >= '#' && c <= '[' || c >= ']' && c <= 'ÿ': - goto yystate27 } yystate28: @@ -344,13 +342,11 @@ yystate30: c = l.next() switch { default: - goto yyabort + goto yystate30 // c >= '\x00' && c <= '&' || c >= '(' && c <= '[' || c >= ']' && c <= 'ÿ' case c == '\'': goto yystate31 case c == '\\': goto yystate32 - case c >= '\x01' && c <= '&' || c >= '(' && c <= '[' || c >= ']' && c <= 'ÿ': - goto yystate30 } yystate31: @@ -414,13 +410,13 @@ yyrule9: // {S}({L}|{D})*= l.offsets = append(l.offsets, l.i-1) goto yystate0 } -yyrule10: // \"(\\.|[^\\"])*\" +yyrule10: // \"(\\.|[^\\"]|\0)*\" { s = lstateLabels l.offsets = append(l.offsets, l.i-1) goto yystate0 } -yyrule11: // \'(\\.|[^\\'])*\' +yyrule11: // \'(\\.|[^\\']|\0)*\' { s = lstateLabels l.offsets = append(l.offsets, l.i-1) diff --git a/pkg/textparse/parse_test.go b/pkg/textparse/parse_test.go index 30464d537..52284d282 100644 --- a/pkg/textparse/parse_test.go +++ b/pkg/textparse/parse_test.go @@ -38,6 +38,7 @@ some:aggregate:rate5m{a_b="c"} 1 # HELP go_goroutines Number of goroutines that currently exist. # TYPE go_goroutines gauge go_goroutines 33 123123` + input += "\nnull_byte_metric{a=\"abc\x00\"} 1" int64p := func(x int64) *int64 { return &x } @@ -72,6 +73,10 @@ go_goroutines 33 123123` v: 33, t: int64p(123123), lset: labels.FromStrings("__name__", "go_goroutines"), + }, { + m: "null_byte_metric{a=\"abc\x00\"}", + v: 1, + lset: labels.FromStrings("__name__", "null_byte_metric", "a", "abc\x00"), }, }