HTML Encoding happens even when equal signs are being used to turn off encoding
marcsantiago opened this issue · 1 comments
marcsantiago commented
The code seems to still encode html entities even when specifying escaping should not happen with the equal sign ({%s= text %}
). It seems the issue is with the file below and it ignoring that encoding should be ignored and is forcing encoding on these characters <, >, ", \, &
The Go standard html/template does this correctly. When you specify a string as template.HTML it does encode ampersands or any other html entity as we've explicitly turn that off.
Whereas with quicktemplate {%s= text %}
works for everything but <, >, ", \, &
package main
import (
"fmt"
"html/template"
"log"
"os"
)
func main() {
check := func(err error) {
if err != nil {
log.Fatal(err)
}
}
markup := `<img src="foobar.com?key=value&key2=value2&key3=value3">`
t, err := template.New("foo").Parse(`{{define "T"}}Hello, {{.}}!{{end}}`)
check(err)
// with HTML encoding e.g & -> &
err = t.ExecuteTemplate(os.Stdout, "T", markup)
check(err)
fmt.Printf("\n\n")
// without HTML encoding & -> &
err = t.ExecuteTemplate(os.Stdout, "T", template.HTML(markup))
check(err)
}
marcsantiago commented
Closing, this is my mistake