Sunday, October 12, 2025
HomeGolangreserved characters escaped in href attribute of A tag utilizing html/template -...

reserved characters escaped in href attribute of A tag utilizing html/template – Getting Assist


I create html utilizing html/template Nonetheless, within the case of the href attribute of the a tag, reserved character escaped by html/template

I do know that reserved characters will not be escaped by rfc 3986 How one can not escape reserved characters in href attribute?

for instance…

dict := make(map[string]interface{})
dict["link"] = `https://instance.com/()"`
tag := `<a href="https://discussion board.golangbridge.org/t/reserved-characters-escaped-in-href-attribute-of-a-tag-using-html-template/{{ $.hyperlink }}"></a>`
t, _ := template.New("tag").Parse(tag)

var tpl bytes.Buffer
e := t.Execute(&tpl, dict)
if e != nil {
    fmt.Println(e)
}

fmt.Println(tpl.String())


// <a href="https://instance.com/%28percent29percent22"></a>

my anticipating

// <a href="https://instance.com/()"></a>

Each URLs are equal representations of the identical ressource.

each appropriate?
I feel p.c encoding just isn’t carried out based on the RFC 3986 spec.

Despite the fact that you need to use numerous characters immediately, the p.c encoding can all the time be used.

Eg. “A” will be written immediately, nonetheless %41 should be handled equivalently.



1 Like

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments