Skip to content

Commit 7ca70f9

Browse files
committed
Decode UTF-8 properly from URLs
1 parent 6c49a1f commit 7ca70f9

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ func DecodeURL(b []byte) []byte {
534534
c = c<<4 + int(b[j]-'a') + 10
535535
}
536536
}
537-
if j == i+3 && c < 128 {
537+
if j == i+3 {
538538
b[i] = byte(c)
539539
b = append(b[:i+1], b[i+3:]...)
540540
}

common_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ func TestParseDataURI(t *testing.T) {
108108
{"data:;base64,()", "", "", base64.CorruptInputError(0)},
109109
{"data:image/svg+xml,%3Cpath%20stroke-width='9.38%'/%3E", "image/svg+xml", "<path stroke-width='9.38%'/>", nil},
110110
{"data:,%ii", "text/plain", "%ii", nil},
111+
{"data:image/svg&#43;xml,%e2%ad%90", "image/svg&#43;xml", "\u2b50", nil},
111112
}
112113
for _, tt := range dataURITests {
113114
t.Run(tt.dataURI, func(t *testing.T) {
@@ -283,7 +284,7 @@ func TestDecodeURL(t *testing.T) {
283284
expected string
284285
}{
285286
{"%20%3F%7E", " ?~"},
286-
{"%80", "%80"},
287+
{"%80", "\x80"},
287288
{"%2B%2b", "++"},
288289
{"%' ", "%' "},
289290
{"a+b", "a b"},

0 commit comments

Comments
 (0)