HTML Template may invalidate URLs encoded using url.QueryEscape

Hey @emb,

Have a look at this question here.

I wrote the poster an answer which I believe answers this question too :slight_smile:

Here’s my answer to the poster’s question: Html/template still escaping template.URL in <a href>?

Basically, encoding with &#43; is still correct and if you run the following for an example, you’ll see it still takes you to the correct link:

package main

import (
	"fmt"
	"log"
	"net/http"
)

func main() {
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		w.Header().Set("Content-Type", "text/html")
		fmt.Fprintln(w, "<a href='http://google.com/?q=hello&#43;world'>hello+world</a>")
	})
	log.Fatal(http.ListenAndServe(":9000", nil))
}
1 Like