forked from DHowett/go-plist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
invalid_text_test.go
54 lines (51 loc) · 1.53 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
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"},
}
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)
}
})
}
}