Data URI: escape space characters as defined as excluded character in RFC2396
Taco de Wolff
2 years ago
273 | 273 | } |
274 | 274 | } |
275 | 275 | |
276 | func TestEncodeDataURI(t *testing.T) { | |
277 | var urlTests = []struct { | |
278 | url string | |
279 | expected string | |
280 | }{ | |
281 | {"a b", "a+b"}, | |
282 | {`<svg xmlns="http://www.w3.org/2000/svg"></svg>`, `%3Csvg+xmlns=%22http://www.w3.org/2000/svg%22%3E%3C/svg%3E`}, | |
283 | } | |
284 | for _, tt := range urlTests { | |
285 | t.Run(tt.url, func(t *testing.T) { | |
286 | b := EncodeURL([]byte(tt.url), DataURIEncodingTable) | |
287 | test.T(t, string(b), tt.expected, "in '"+tt.url+"'") | |
288 | }) | |
289 | } | |
290 | } | |
291 | ||
276 | 292 | func TestEncodeURLRandom(t *testing.T) { |
277 | 293 | for _, e := range urlSlices { |
278 | 294 | reference := url.QueryEscape(string(e)) |