forked from pierrejoye/php_zip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoo_setcomment_error.phpt
44 lines (36 loc) · 1.07 KB
/
oo_setcomment_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
--TEST--
setComment error behavior
--SKIPIF--
<?php
if(!extension_loaded('zip')) die('skip zip extension not available');
if (PHP_VERSION_ID >= 80000) die('skip PHP < 8 only');
?>
--FILE--
<?php
$file = __DIR__ . '/__tmp_oo_set_comment_error.zip';
@unlink($file);
$zip = new ZipArchive;
if (!$zip->open($file, ZIPARCHIVE::CREATE)) {
exit('failed');
}
$zip->addFromString('entry1.txt', 'entry #1');
$zip->addFromString('entry2.txt', 'entry #2');
$longComment = str_repeat('a', 0x10000);
var_dump($zip->setArchiveComment($longComment));
var_dump($zip->setCommentName('entry1.txt', $longComment));
var_dump($zip->setCommentIndex(1, $longComment));
$zip->close();
?>
===DONE===
--EXPECTF--
Warning: ZipArchive::setArchiveComment(): Comment must not exceed 65535 bytes in %s on line %d
bool(false)
Warning: ZipArchive::setCommentName(): Comment must not exceed 65535 bytes in %s on line %d
bool(false)
Warning: ZipArchive::setCommentIndex(): Comment must not exceed 65535 bytes in %s on line %d
bool(false)
===DONE===
--CLEAN--
<?php
@unlink(__DIR__ . '/__tmp_oo_set_comment_error.zip');
?>