shithub: hugo

Download patch

ref: 55a4f6e48e381fffe33eba71ff6a08c593b1c2c7
parent: ef9b915680e21d5ab5fceb7c7957fd0b626942a7
author: Cathal Garvey <[email protected]>
date: Thu Jul 14 10:53:33 EDT 2016

Do not double-escape in querify

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

Fixes #2279

--- a/tpl/template_funcs.go
+++ b/tpl/template_funcs.go
@@ -1769,7 +1769,7 @@
 	}
 
 	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
--- a/tpl/template_funcs_test.go
+++ b/tpl/template_funcs_test.go
@@ -103,7 +103,7 @@
 mul: {{mul 2 3}}
 plainify: {{ plainify  "Hello <strong>world</strong>, gophers!" }}
 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 }}
 readFile: {{ readFile "README.txt" }}
 relURL 1: {{ "http://gohugo.io/" | relURL }}
@@ -155,7 +155,7 @@
 mul: 6
 plainify: Hello world, gophers!
 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
 readFile: Hugo Rocks!
 relURL 1: http://gohugo.io/