-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathgetparty_test.go
66 lines (63 loc) · 1.14 KB
/
getparty_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package getparty
import "testing"
func TestParseContentDisposition(t *testing.T) {
tests := []struct {
input string
output string
}{
{
input: "",
output: "",
},
{
input: "garbage",
output: "",
},
{
input: "attachment; filename=",
output: "",
},
{
input: "attachment; filename=''",
output: "",
},
{
input: `attachment; filename=""`,
output: "",
},
{
input: "attachment; garbage=filename",
output: "",
},
{
input: "attachment; filename=filename",
output: "filename",
},
{
input: "attachment; filename=content.txt",
output: "content.txt",
},
{
input: "attachment; filename='content.txt'",
output: "content.txt",
},
{
input: `attachment; filename="content.txt"`,
output: "content.txt",
},
{
input: "attachment; filename*=UTF-8''content.txt",
output: "content.txt",
},
{
input: "attachment; filename*=utf-8''%e2%82%ac%20rates",
output: "€ rates",
},
}
for _, test := range tests {
output := parseContentDisposition(test.input)
if output != test.output {
t.Errorf("expected %q got %q", test.output, output)
}
}
}