From ac51a8024cf6a8134b9345673f8a685846c6a6fc Mon Sep 17 00:00:00 2001 From: Owen Williams Date: Tue, 27 Feb 2024 15:47:47 -0500 Subject: [PATCH] tests(utf8): confirm that other quote marks are handled correctly in promql Signed-off-by: Owen Williams --- promql/parser/parse_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/promql/parser/parse_test.go b/promql/parser/parse_test.go index 2d5f59da0a..bd696ae969 100644 --- a/promql/parser/parse_test.go +++ b/promql/parser/parse_test.go @@ -1731,6 +1731,34 @@ var testExpr = []struct { }, }, }, + { + input: `{'foo\'bar', 'a\\dos\\path'='boo\\urns'}`, + expected: &VectorSelector{ + // When a metric is named inside the braces, the Name field is not set. + LabelMatchers: []*labels.Matcher{ + MustLabelMatcher(labels.MatchEqual, model.MetricNameLabel, `foo'bar`), + MustLabelMatcher(labels.MatchEqual, `a\dos\path`, `boo\urns`), + }, + PosRange: posrange.PositionRange{ + Start: 0, + End: 40, + }, + }, + }, + { + input: `{'foo\'bar', ` + "`" + `a\dos\path` + "`" + `="boo"}`, + expected: &VectorSelector{ + // When a metric is named inside the braces, the Name field is not set. + LabelMatchers: []*labels.Matcher{ + MustLabelMatcher(labels.MatchEqual, model.MetricNameLabel, `foo'bar`), + MustLabelMatcher(labels.MatchEqual, `a\dos\path`, "boo"), + }, + PosRange: posrange.PositionRange{ + Start: 0, + End: 32, + }, + }, + }, { input: `{"foo", a="bc"}`, expected: &VectorSelector{