mirror of https://github.com/prometheus/prometheus
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>pull/8523/head
parent
423bde533c
commit
42a0e0acad
|
@ -583,8 +583,12 @@ func lexEscape(l *Lexer) stateFn {
|
||||||
return lexString
|
return lexString
|
||||||
}
|
}
|
||||||
x = x*base + d
|
x = x*base + d
|
||||||
ch = l.next()
|
|
||||||
n--
|
n--
|
||||||
|
|
||||||
|
// Don't seek after last rune.
|
||||||
|
if n > 0 {
|
||||||
|
ch = l.next()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if x > max || 0xD800 <= x && x < 0xE000 {
|
if x > max || 0xD800 <= x && x < 0xE000 {
|
||||||
|
|
|
@ -3274,6 +3274,16 @@ var testSeries = []struct {
|
||||||
input: `my_metric{a="b"} 1 2 3 `,
|
input: `my_metric{a="b"} 1 2 3 `,
|
||||||
expectedMetric: labels.FromStrings(labels.MetricName, "my_metric", "a", "b"),
|
expectedMetric: labels.FromStrings(labels.MetricName, "my_metric", "a", "b"),
|
||||||
expectedValues: newSeq(1, 2, 3),
|
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`,
|
input: `my_metric{a="b"} -3-3 -3`,
|
||||||
fail: true,
|
fail: true,
|
||||||
|
|
Loading…
Reference in New Issue