1--TEST--
2Errors from __unserialize() with invalid data
3--FILE--
4<?php
5
6echo "ArrayObject:\n";
7
8try {
9    // empty array
10    unserialize('O:11:"ArrayObject":0:{}');
11} catch (Exception $e) {
12    echo $e->getMessage(), "\n";
13}
14
15try {
16    unserialize('O:11:"ArrayObject":3:{i:0;b:1;i:1;a:0:{}i:2;a:0:{}}');
17} catch (Exception $e) {
18    echo $e->getMessage(), "\n";
19}
20
21try {
22    unserialize('O:11:"ArrayObject":3:{i:0;i:0;i:1;a:0:{}i:2;i:0;}');
23} catch (Exception $e) {
24    echo $e->getMessage(), "\n";
25}
26
27try {
28    unserialize('O:11:"ArrayObject":3:{i:0;i:0;i:1;i:0;i:2;a:0:{}}');
29} catch (Exception $e) {
30    echo $e->getMessage(), "\n";
31}
32
33try {
34    // iterator class name is not a string
35    unserialize('O:11:"ArrayObject":4:{i:0;i:0;i:1;i:0;i:2;a:0:{}i:3;i:0;}');
36} catch (Exception $e) {
37    echo $e->getMessage(), "\n";
38}
39
40try {
41    unserialize('O:11:"ArrayObject":4:{i:0;i:0;i:1;a:2:{i:0;i:1;i:1;i:2;}i:2;a:0:{}i:3;s:11:"NonExistent";}');
42} catch (Exception $e) {
43    echo $e->getMessage(), "\n";
44}
45
46class Existent {}
47
48try {
49    unserialize('O:11:"ArrayObject":4:{i:0;i:0;i:1;a:2:{i:0;i:1;i:1;i:2;}i:2;a:0:{}i:3;s:8:"Existent";}');
50} catch (Exception $e) {
51    echo $e->getMessage(), "\n";
52}
53
54echo "ArrayIterator:\n";
55
56try {
57    unserialize('O:13:"ArrayIterator":0:{}');
58} catch (Exception $e) {
59    echo $e->getMessage(), "\n";
60}
61
62try {
63    unserialize('O:13:"ArrayIterator":3:{i:0;b:1;i:1;a:0:{}i:2;a:0:{}}');
64} catch (Exception $e) {
65    echo $e->getMessage(), "\n";
66}
67
68try {
69    unserialize('O:13:"ArrayIterator":3:{i:0;i:0;i:1;a:0:{}i:2;i:0;}');
70} catch (Exception $e) {
71    echo $e->getMessage(), "\n";
72}
73
74try {
75    unserialize('O:13:"ArrayIterator":3:{i:0;i:0;i:1;i:0;i:2;a:0:{}}');
76} catch (Exception $e) {
77    echo $e->getMessage(), "\n";
78}
79
80echo "SplDoublyLinkedList:\n";
81
82try {
83    unserialize('O:19:"SplDoublyLinkedList":0:{}');
84} catch (Exception $e) {
85    echo $e->getMessage(), "\n";
86}
87
88try {
89    unserialize('O:19:"SplDoublyLinkedList":3:{i:0;b:1;i:1;a:0:{}i:2;a:0:{}}');
90} catch (Exception $e) {
91    echo $e->getMessage(), "\n";
92}
93
94try {
95    unserialize('O:19:"SplDoublyLinkedList":3:{i:0;i:0;i:1;a:0:{}i:2;i:0;}');
96} catch (Exception $e) {
97    echo $e->getMessage(), "\n";
98}
99
100try {
101    unserialize('O:19:"SplDoublyLinkedList":3:{i:0;i:0;i:1;i:0;i:2;a:0:{}}');
102} catch (Exception $e) {
103    echo $e->getMessage(), "\n";
104}
105
106echo "SplObjectStorage:\n";
107
108try {
109    unserialize('O:16:"SplObjectStorage":0:{}');
110} catch (Exception $e) {
111    echo $e->getMessage(), "\n";
112}
113
114try {
115    unserialize('O:16:"SplObjectStorage":2:{i:0;i:0;i:1;a:0:{}}');
116} catch (Exception $e) {
117    echo $e->getMessage(), "\n";
118}
119
120try {
121    unserialize('O:16:"SplObjectStorage":2:{i:0;a:0:{}i:1;i:1;}');
122} catch (Exception $e) {
123    echo $e->getMessage(), "\n";
124}
125
126try {
127    unserialize('O:16:"SplObjectStorage":2:{i:0;a:1:{i:0;i:0;}i:1;a:0:{}}');
128} catch (Exception $e) {
129    echo $e->getMessage(), "\n";
130}
131
132try {
133    unserialize('O:16:"SplObjectStorage":2:{i:0;a:2:{i:0;i:0;i:1;i:0;}i:1;a:0:{}}');
134} catch (Exception $e) {
135    echo $e->getMessage(), "\n";
136}
137
138?>
139--EXPECT--
140ArrayObject:
141Incomplete or ill-typed serialization data
142Incomplete or ill-typed serialization data
143Incomplete or ill-typed serialization data
144Passed variable is not an array or object
145Incomplete or ill-typed serialization data
146Cannot deserialize ArrayObject with iterator class 'NonExistent'; no such class exists
147Cannot deserialize ArrayObject with iterator class 'Existent'; this class does not implement the Iterator interface
148ArrayIterator:
149Incomplete or ill-typed serialization data
150Incomplete or ill-typed serialization data
151Incomplete or ill-typed serialization data
152Passed variable is not an array or object
153SplDoublyLinkedList:
154Incomplete or ill-typed serialization data
155Incomplete or ill-typed serialization data
156Incomplete or ill-typed serialization data
157Incomplete or ill-typed serialization data
158SplObjectStorage:
159Incomplete or ill-typed serialization data
160Incomplete or ill-typed serialization data
161Incomplete or ill-typed serialization data
162Odd number of elements
163Non-object key
164