Skip to content

Commit

Permalink
Fix URI encoding of strings
Browse files Browse the repository at this point in the history
Signed-off-by: Kartikay <kartikay_2101ce32@iitp.ac.in>
  • Loading branch information
kartikaysaxena committed Dec 27, 2023
1 parent 480c8d9 commit 31850ab
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
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

0 comments on commit 31850ab

Please sign in to comment.