mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-12 06:17:27 -08:00
Prevent lexer from seeking to next rune after lexing escape sequence. (#8517)
* Prevent lexer from seeking to next rune after lexing escape sequence. Signed-off-by: Danny Kopping <danny.kopping@grafana.com>
This commit is contained in:
parent
423bde533c
commit
42a0e0acad
|
@ -583,8 +583,12 @@ func lexEscape(l *Lexer) stateFn {
|
|||
return lexString
|
||||
}
|
||||
x = x*base + d
|
||||
ch = l.next()
|
||||
n--
|
||||
|
||||
// Don't seek after last rune.
|
||||
if n > 0 {
|
||||
ch = l.next()
|
||||
}
|
||||
}
|
||||
|
||||
if x > max || 0xD800 <= x && x < 0xE000 {
|
||||
|
|
|
@ -3274,6 +3274,16 @@ var testSeries = []struct {
|
|||
input: `my_metric{a="b"} 1 2 3 `,
|
||||
expectedMetric: labels.FromStrings(labels.MetricName, "my_metric", "a", "b"),
|
||||
expectedValues: newSeq(1, 2, 3),
|
||||
}, {
|
||||
// Handle escaped unicode characters as whole label values.
|
||||
input: `my_metric{a="\u70ac"} 1 2 3`,
|
||||
expectedMetric: labels.FromStrings(labels.MetricName, "my_metric", "a", `炬`),
|
||||
expectedValues: newSeq(1, 2, 3),
|
||||
}, {
|
||||
// Handle escaped unicode characters as partial label values.
|
||||
input: `my_metric{a="\u70ac = torch"} 1 2 3`,
|
||||
expectedMetric: labels.FromStrings(labels.MetricName, "my_metric", "a", `炬 = torch`),
|
||||
expectedValues: newSeq(1, 2, 3),
|
||||
}, {
|
||||
input: `my_metric{a="b"} -3-3 -3`,
|
||||
fail: true,
|
||||
|
|
Loading…
Reference in a new issue