-
Notifications
You must be signed in to change notification settings - Fork 97
/
invalid_text_test.go
65 lines (62 loc) · 2.12 KB
/
invalid_text_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
package plist
import (
"strings"
"testing"
)
var InvalidTextPlists = []struct {
Name string
Data string
}{
{"Truncated array", "("},
{"Truncated dictionary", "{a=b;"},
{"Truncated dictionary 2", "{"},
{"Unclosed nested array", "{0=(/"},
{"Unclosed dictionary", "{0=/"},
{"Broken GNUStep data", "(<*I5>,<*I5>,<*I5>,<*I5>,*I16777215>,<*I268435455>,<*I4294967295>,<*I18446744073709551615>,)"},
{"Truncated nested array", "{0=(((/"},
{"Truncated dictionary with comment-like", "{/"},
{"Truncated array with comment-like", "(/"},
{"Truncated array with empty data", "(<>"},
{"Bad Extended Character", "{¬=A;}"},
{"Missing Equals in Dictionary", `{"A"A;}`},
{"Missing Semicolon in Dictionary", `{"A"=A}`},
{"Invalid GNUStep type", "<*F33>"},
{"Invalid GNUStep int", "(<*I>"},
{"Invalid GNUStep date", "<*D5>"},
{"Truncated GNUStep value", "<*I3"},
{"Invalid data", "<EQ>"},
{"Truncated unicode escape", `"\u231`},
{"Truncated hex escape", `"\x2`},
{"Truncated octal escape", `"\02`},
{"Truncated data", `<33`},
{"Uneven data", `<3>`},
{"Truncated block comment", `/* hello`},
{"Truncated quoted string", `"hi`},
{"Garbage after end of non-string", "<ab> cde"},
{"Broken UTF-16", "\xFE\xFF\x01"},
{"Truncated GNUStep data", "<"},
{"Truncated GNUStep base64 data (missing ])", `<[33==`},
{"Truncated GNUStep base64 data (missing >)", `<[33==]`},
{"Invalid GNUStep base64 data", `<[3]>`}, // TODO: this is actually valid
{"GNUStep extended value with EOF before type", "<*"},
{"GNUStep extended value terminated before type", "<*>"},
{"Empty GNUStep extended value", "<*I>"},
{"Unterminated GNUStep quoted value", "<*D\"5>"},
{"Unterminated GNUStep quoted value (EOF)", "<*D\""},
{"Poorly-terminated GNUStep quoted value", "<*D\">"},
{"Empty GNUStep quoted extended value", "<*D\"\">"},
}
func TestInvalidTextPlists(t *testing.T) {
for _, test := range InvalidTextPlists {
subtest(t, test.Name, func(t *testing.T) {
var obj interface{}
buf := strings.NewReader(test.Data)
err := NewDecoder(buf).Decode(&obj)
if err == nil {
t.Fatal("invalid plist failed to throw error")
} else {
t.Log(err)
}
})
}
}