mirror of https://github.com/prometheus/prometheus
Handle empty HELP in text parser. (#4444)
Fixes #4427 Signed-off-by: Brian Brazil <brian.brazil@robustperception.io>pull/4445/merge
parent
7608ee87d0
commit
70c98a06f1
|
@ -64,7 +64,7 @@ C [^\n]
|
||||||
<sComment>HELP[\t ]+ l.state = sMeta1; return tHelp
|
<sComment>HELP[\t ]+ l.state = sMeta1; return tHelp
|
||||||
<sComment>TYPE[\t ]+ l.state = sMeta1; return tType
|
<sComment>TYPE[\t ]+ l.state = sMeta1; return tType
|
||||||
<sMeta1>{M}({M}|{D})* l.state = sMeta2; return tMName
|
<sMeta1>{M}({M}|{D})* l.state = sMeta2; return tMName
|
||||||
<sMeta2>{C}+ l.state = sInit; return tText
|
<sMeta2>{C}* l.state = sInit; return tText
|
||||||
|
|
||||||
{M}({M}|{D})* l.state = sValue; return tMName
|
{M}({M}|{D})* l.state = sValue; return tMName
|
||||||
<sValue>\{ l.state = sLabels; return tBraceOpen
|
<sValue>\{ l.state = sLabels; return tBraceOpen
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by golex. DO NOT EDIT.
|
// CAUTION: Generated file - DO NOT EDIT.
|
||||||
|
|
||||||
// Copyright 2017 The Prometheus Authors
|
// Copyright 2017 The Prometheus Authors
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@ -260,7 +260,7 @@ yystate21:
|
||||||
yystart21:
|
yystart21:
|
||||||
switch {
|
switch {
|
||||||
default:
|
default:
|
||||||
goto yyabort
|
goto yyrule9
|
||||||
case c == '\t' || c == ' ':
|
case c == '\t' || c == ' ':
|
||||||
goto yystate23
|
goto yystate23
|
||||||
case c >= '\x01' && c <= '\b' || c >= '\v' && c <= '\x1f' || c >= '!' && c <= 'ÿ':
|
case c >= '\x01' && c <= '\b' || c >= '\v' && c <= '\x1f' || c >= '!' && c <= 'ÿ':
|
||||||
|
@ -463,7 +463,7 @@ yyrule8: // {M}({M}|{D})*
|
||||||
return tMName
|
return tMName
|
||||||
goto yystate0
|
goto yystate0
|
||||||
}
|
}
|
||||||
yyrule9: // {C}+
|
yyrule9: // {C}*
|
||||||
{
|
{
|
||||||
l.state = sInit
|
l.state = sInit
|
||||||
return tText
|
return tText
|
||||||
|
|
|
@ -281,7 +281,11 @@ func (p *Parser) Next() (Entry, error) {
|
||||||
}
|
}
|
||||||
switch t := p.nextToken(); t {
|
switch t := p.nextToken(); t {
|
||||||
case tText:
|
case tText:
|
||||||
|
if len(p.l.buf()) > 1 {
|
||||||
p.text = p.l.buf()[1:]
|
p.text = p.l.buf()[1:]
|
||||||
|
} else {
|
||||||
|
p.text = []byte{}
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return EntryInvalid, parseError("expected text in HELP", t)
|
return EntryInvalid, parseError("expected text in HELP", t)
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,8 @@ go_gc_duration_seconds{ quantile="0.9", a="b"} 8.3835e-05
|
||||||
#
|
#
|
||||||
# comment with escaped \n newline
|
# comment with escaped \n newline
|
||||||
# comment with escaped \ escape character
|
# comment with escaped \ escape character
|
||||||
|
# HELP nohelp1
|
||||||
|
# HELP nohelp2
|
||||||
go_gc_duration_seconds{ quantile="1.0", a="b" } 8.3835e-05
|
go_gc_duration_seconds{ quantile="1.0", a="b" } 8.3835e-05
|
||||||
go_gc_duration_seconds { quantile="1.0", a="b" } 8.3835e-05
|
go_gc_duration_seconds { quantile="1.0", a="b" } 8.3835e-05
|
||||||
go_gc_duration_seconds { quantile= "1.0", a= "b", } 8.3835e-05
|
go_gc_duration_seconds { quantile= "1.0", a= "b", } 8.3835e-05
|
||||||
|
@ -99,6 +101,12 @@ testmetric{label="\"bar\""} 1`
|
||||||
comment: "# comment with escaped \\n newline",
|
comment: "# comment with escaped \\n newline",
|
||||||
}, {
|
}, {
|
||||||
comment: "# comment with escaped \\ escape character",
|
comment: "# comment with escaped \\ escape character",
|
||||||
|
}, {
|
||||||
|
m: "nohelp1",
|
||||||
|
help: "",
|
||||||
|
}, {
|
||||||
|
m: "nohelp2",
|
||||||
|
help: "",
|
||||||
}, {
|
}, {
|
||||||
m: `go_gc_duration_seconds{ quantile="1.0", a="b" }`,
|
m: `go_gc_duration_seconds{ quantile="1.0", a="b" }`,
|
||||||
v: 8.3835e-05,
|
v: 8.3835e-05,
|
||||||
|
|
Loading…
Reference in New Issue