Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule: Fix URI encoding of strings #7009

Merged
merged 1 commit into from Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -13,6 +13,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re
### Fixed

- [#6874](https://github.com/thanos-io/thanos/pull/6874) Sidecar: fix labels returned by 'api/v1/series' in presence of conflicting external and inner labels.
- [#7009](https://github.com/thanos-io/thanos/pull/7009) Rule: Fix spacing error in URL.

### Added
- [#6944](https://github.com/thanos-io/thanos/pull/6944) Receive: Added a new flag for maximum retention bytes.
Expand Down
3 changes: 2 additions & 1 deletion cmd/thanos/rule.go
Expand Up @@ -16,6 +16,7 @@ import (
"sort"
"strconv"
"strings"
texttemplate "text/template"
"time"

extflag "github.com/efficientgo/tools/extkingpin"
Expand Down Expand Up @@ -939,7 +940,7 @@ func tableLinkForExpression(tmpl string, expr string) (string, error) {
escapedExpression := url.QueryEscape(expr)

escapedExpr := Expression{Expr: escapedExpression}
t, err := template.New("url").Parse(tmpl)
t, err := texttemplate.New("url").Parse(tmpl)
if err != nil {
return "", errors.Wrap(err, "failed to parse template")
}
Expand Down
6 changes: 6 additions & 0 deletions cmd/thanos/rule_test.go
Expand Up @@ -86,6 +86,12 @@ func Test_tableLinkForExpression(t *testing.T) {
expectStr: `/graph?g0.expr=up%7Bapp%3D%22foo%22%7D&g0.tab=1`,
expectErr: false,
},
{
template: `/graph?g0.expr={{.Expr}}&g0.tab=1`,
expr: `up{app="foo yoo"}`,
expectStr: `/graph?g0.expr=up%7Bapp%3D%22foo+yoo%22%7D&g0.tab=1`,
expectErr: false,
},
{
template: `/graph?g0.expr={{.Expression}}&g0.tab=1`,
expr: "test_expr",
Expand Down