Skip to content

Commit

Permalink
Data URI: escape space characters as defined as excluded character in…
Browse files Browse the repository at this point in the history
… RFC2396
  • Loading branch information
tdewolff committed Apr 5, 2022
1 parent 7054e8c commit 8a4cf11
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,22 @@ func TestEncodeURL(t *testing.T) {
}
}

func TestEncodeDataURI(t *testing.T) {
var urlTests = []struct {
url string
expected string
}{
{"a b", "a+b"},
{`<svg xmlns="http://www.w3.org/2000/svg"></svg>`, `%3Csvg+xmlns=%22http://www.w3.org/2000/svg%22%3E%3C/svg%3E`},
}
for _, tt := range urlTests {
t.Run(tt.url, func(t *testing.T) {
b := EncodeURL([]byte(tt.url), DataURIEncodingTable)
test.T(t, string(b), tt.expected, "in '"+tt.url+"'")
})
}
}

func TestEncodeURLRandom(t *testing.T) {
for _, e := range urlSlices {
reference := url.QueryEscape(string(e))
Expand Down

0 comments on commit 8a4cf11

Please sign in to comment.