Re: [go-nuts] html/template: urlEscaper uses small letters to escape, whereas URLQueryEscaper uses capitals

2018-04-20 Thread Ian Lance Taylor
On Thu, Apr 19, 2018 at 9:35 PM,   wrote:
>
> i noticed that html/template escapes a URI using small letters. For example,
> the following code outputs "%e5%af%bf%e5%8f%b8", not "%E5%AF%BF%E5%8F%B8".
>
> t, _ := template.New("foo").Parse(`{{define "T"}} href="/{{.}}">{{end}}`)
> t.ExecuteTemplate(os.Stdout, "T", "寿司")
> (See https://play.golang.org/p/9caza-3ojur )
>
> This behavior is different from what template.URLQueryEscaper does. Also,
> this is invalid with URL Standard (
> https://url.spec.whatwg.org/#percent-encoded-bytes ). RFC 3986 Section 2.1
> says "For consistency, URI producers and normalizers should use uppercase
> hexadecimal digits for all percent-encodings."
>
> It seems that this line generates these small letters. So we can fix this
> just by changing x to X.
>
> But this behavior has remained for several years. Therefore I want to
> confirm that this should be fixed, before filing an issue or sending a pull
> req. Am I missing something?

I guess we should try following the RFC.  Thanks.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] html/template: urlEscaper uses small letters to escape, whereas URLQueryEscaper uses capitals

2018-04-20 Thread nekketsuuu
i noticed that html/template escapes a URI using small letters. For 
example, the following code outputs "%e5%af%bf%e5%8f%b8", not "
%E5%AF%BF%E5%8F%B8".

t, _ := template.New("foo").Parse(`{{define "T"}}{{end}}`)
t.ExecuteTemplate(os.Stdout, "T", "寿司")
(See https://play.golang.org/p/9caza-3ojur )

This behavior is different from what template.URLQueryEscaper does. Also, 
this is invalid with URL Standard ( 
https://url.spec.whatwg.org/#percent-encoded-bytes ). RFC 3986 Section 2.1 
 says "For consistency, 
URI producers and normalizers should use uppercase hexadecimal digits for 
all percent-encodings."

It seems that this line 

 generates 
these small letters. So we can fix this just by changing x to X.

But this behavior has remained for several years. Therefore I want to 
confirm that this should be fixed, before filing an issue or sending a pull 
req. Am I missing something?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.