Merge pull request #2764 from prometheus/nullparse

pkg/textparse: allow null bytes in label values
This commit is contained in:
Fabian Reinartz 2017-05-24 15:24:38 +02:00 committed by GitHub
commit 10d8b6b633
3 changed files with 11 additions and 10 deletions

View File

@ -81,9 +81,9 @@ M [a-zA-Z_:]
<lstateLName>{S}({L}|{D})*= s = lstateLValue
l.offsets = append(l.offsets, l.i-1)
<lstateLValue>\"(\\.|[^\\"])*\" s = lstateLabels
<lstateLValue>\"(\\.|[^\\"]|\0)*\" s = lstateLabels
l.offsets = append(l.offsets, l.i-1)
<lstateLValue>\'(\\.|[^\\'])*\' s = lstateLabels
<lstateLValue>\'(\\.|[^\\']|\0)*\' s = lstateLabels
l.offsets = append(l.offsets, l.i-1)
<lstateValue>[ \t]+ l.vstart = l.i

View File

@ -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)

View File

@ -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"),
},
}