Skip to content

Commit 8ef03e9

Browse files
committed
Unescape server path when building resource
1 parent e5d6639 commit 8ef03e9

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

http.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"encoding/base64"
55
"fmt"
66
"net/http"
7+
"net/url"
78
"strings"
89
"time"
910

@@ -64,5 +65,9 @@ func clientResource(r *http.Request) string {
6465
}
6566

6667
func serverResource(r *http.Request) string {
67-
return fmt.Sprintf("%s %s%s", r.Method, r.Host, r.URL)
68+
path, err := url.PathUnescape(r.URL.Path)
69+
if err != nil {
70+
path = r.URL.Path
71+
}
72+
return fmt.Sprintf("%s %s%s", r.Method, r.Host, path)
6873
}

http_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,15 @@ func TestHttp(t *testing.T) {
202202
}
203203
}
204204
}
205+
206+
func TestUnicode(t *testing.T) {
207+
ks, priv := generateKey(t, "bob")
208+
url := startServer(t, ks)
209+
r := get(t, url+`/+++/föö/bär/🚀/foo%20bar/`, authorize(priv))
210+
if r.Err != "" {
211+
t.Fatal(r.Err)
212+
}
213+
if r.Subject != "bob" {
214+
t.Fatalf("want subject bob, got %q", r.Subject)
215+
}
216+
}

0 commit comments

Comments
 (0)