Do not double-escape in querify

Test case modified and expanded for querify to reflect original bug and changes.

Fixes #2279
This commit is contained in:
Cathal Garvey 2016-07-14 14:53:33 +01:00 committed by Bjørn Erik Pedersen
parent ef9b915680
commit 55a4f6e48e
2 changed files with 3 additions and 3 deletions

View file

@ -1769,7 +1769,7 @@ func querify(params ...interface{}) (string, error) {
} }
for name, value := range vals { for name, value := range vals {
qs.Add(name, url.QueryEscape(fmt.Sprintf("%v", value))) qs.Add(name, fmt.Sprintf("%v", value))
} }
return qs.Encode(), nil return qs.Encode(), nil

View file

@ -103,7 +103,7 @@ modBool: {{modBool 15 3}}
mul: {{mul 2 3}} mul: {{mul 2 3}}
plainify: {{ plainify "Hello <strong>world</strong>, gophers!" }} plainify: {{ plainify "Hello <strong>world</strong>, gophers!" }}
pluralize: {{ "cat" | pluralize }} pluralize: {{ "cat" | pluralize }}
querify: {{ (querify "foo" 1 "bar" 2 "baz" "with spaces") | safeHTML }} querify: {{ (querify "foo" 1 "bar" 2 "baz" "with spaces" "qux" "this&that=those") | safeHTML }}
readDir: {{ range (readDir ".") }}{{ .Name }}{{ end }} readDir: {{ range (readDir ".") }}{{ .Name }}{{ end }}
readFile: {{ readFile "README.txt" }} readFile: {{ readFile "README.txt" }}
relURL 1: {{ "http://gohugo.io/" | relURL }} relURL 1: {{ "http://gohugo.io/" | relURL }}
@ -155,7 +155,7 @@ modBool: true
mul: 6 mul: 6
plainify: Hello world, gophers! plainify: Hello world, gophers!
pluralize: cats pluralize: cats
querify: bar=2&baz=with%2Bspaces&foo=1 querify: bar=2&baz=with+spaces&foo=1&qux=this%26that%3Dthose
readDir: README.txt readDir: README.txt
readFile: Hugo Rocks! readFile: Hugo Rocks!
relURL 1: http://gohugo.io/ relURL 1: http://gohugo.io/