Skip to content

Commit

Permalink
Merge pull request #7009 from kartikaysaxena/url_template
Browse files Browse the repository at this point in the history
Rule: Fix URI encoding of strings
  • Loading branch information
MichaHoffmann authored Dec 27, 2023
2 parents ed8a317 + 31850ab commit ee9288f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"sort"
"strconv"
"strings"
texttemplate "text/template"
"time"

extflag "github.com/efficientgo/tools/extkingpin"
Expand Down Expand Up @@ -1059,7 +1060,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
Original file line number Diff line number Diff line change
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

0 comments on commit ee9288f

Please sign in to comment.