mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
Handle empty HELP in text parser. (#4444)
Fixes #4427 Signed-off-by: Brian Brazil <brian.brazil@robustperception.io>
This commit is contained in:
parent
7608ee87d0
commit
70c98a06f1
|
@ -64,7 +64,7 @@ C [^\n]
|
|||
<sComment>HELP[\t ]+ l.state = sMeta1; return tHelp
|
||||
<sComment>TYPE[\t ]+ l.state = sMeta1; return tType
|
||||
<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
|
||||
<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
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -260,7 +260,7 @@ yystate21:
|
|||
yystart21:
|
||||
switch {
|
||||
default:
|
||||
goto yyabort
|
||||
goto yyrule9
|
||||
case c == '\t' || c == ' ':
|
||||
goto yystate23
|
||||
case c >= '\x01' && c <= '\b' || c >= '\v' && c <= '\x1f' || c >= '!' && c <= 'ÿ':
|
||||
|
@ -463,7 +463,7 @@ yyrule8: // {M}({M}|{D})*
|
|||
return tMName
|
||||
goto yystate0
|
||||
}
|
||||
yyrule9: // {C}+
|
||||
yyrule9: // {C}*
|
||||
{
|
||||
l.state = sInit
|
||||
return tText
|
||||
|
|
|
@ -281,7 +281,11 @@ func (p *Parser) Next() (Entry, error) {
|
|||
}
|
||||
switch t := p.nextToken(); t {
|
||||
case tText:
|
||||
p.text = p.l.buf()[1:]
|
||||
if len(p.l.buf()) > 1 {
|
||||
p.text = p.l.buf()[1:]
|
||||
} else {
|
||||
p.text = []byte{}
|
||||
}
|
||||
default:
|
||||
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 \ 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
|
||||
|
@ -99,6 +101,12 @@ testmetric{label="\"bar\""} 1`
|
|||
comment: "# comment with escaped \\n newline",
|
||||
}, {
|
||||
comment: "# comment with escaped \\ escape character",
|
||||
}, {
|
||||
m: "nohelp1",
|
||||
help: "",
|
||||
}, {
|
||||
m: "nohelp2",
|
||||
help: "",
|
||||
}, {
|
||||
m: `go_gc_duration_seconds{ quantile="1.0", a="b" }`,
|
||||
v: 8.3835e-05,
|
||||
|
|
Loading…
Reference in a new issue