forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetrawcookie_error.phpt
62 lines (56 loc) · 1.52 KB
/
setrawcookie_error.phpt
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
--TEST--
setrawcookie() error tests
--INI--
date.timezone=UTC
--FILE--
<?php
ob_start();
try {
setrawcookie('');
} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
try {
setrawcookie('invalid=');
} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
try {
setrawcookie('name', 'invalid;');
} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
try {
setrawcookie('name', 'value', 100, 'invalid;');
} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
try {
setrawcookie('name', 'value', 100, 'path', 'invalid;');
} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
if (PHP_INT_SIZE == 8) {
try {
// To go above year 9999: 60 * 60 * 24 * 365 * 9999
setrawcookie('name', 'value', 315328464000);
} catch (\ValueError $e) {
var_dump($e->getMessage() == 'setrawcookie(): "expires" option cannot have a year greater than 9999');
}
} else {
var_dump(true);
}
var_dump(headers_list());
?>
--EXPECTHEADERS--
--EXPECTF--
setrawcookie(): Argument #1 ($name) must not be empty
setrawcookie(): Argument #1 ($name) cannot contain "=", ",", ";", " ", "\t", "\r", "\n", "\013", or "\014"
setrawcookie(): Argument #2 ($value) cannot contain ",", ";", " ", "\t", "\r", "\n", "\013", or "\014"
setrawcookie(): "path" option cannot contain ",", ";", " ", "\t", "\r", "\n", "\013", or "\014"
setrawcookie(): "domain" option cannot contain ",", ";", " ", "\t", "\r", "\n", "\013", or "\014"
bool(true)
array(1) {
[0]=>
string(%d) "X-Powered-By: PHP/%s"
}