1--TEST-- 2setComment error behavior 3--EXTENSIONS-- 4zip 5--FILE-- 6<?php 7$file = __DIR__ . '/__tmp_oo_set_comment_error.zip'; 8 9@unlink($file); 10 11$zip = new ZipArchive; 12if (!$zip->open($file, ZIPARCHIVE::CREATE)) { 13 exit('failed'); 14} 15 16$zip->addFromString('entry1.txt', 'entry #1'); 17$zip->addFromString('entry2.txt', 'entry #2'); 18 19$longComment = str_repeat('a', 0x10000); 20 21try { 22 var_dump($zip->setArchiveComment($longComment)); 23} catch (\ValueError $e) { 24 echo $e->getMessage() . \PHP_EOL; 25} 26try { 27 var_dump($zip->setCommentName('entry1.txt', $longComment)); 28} catch (\ValueError $e) { 29 echo $e->getMessage() . \PHP_EOL; 30} 31try { 32 var_dump($zip->setCommentIndex(1, $longComment)); 33} catch (\ValueError $e) { 34 echo $e->getMessage() . \PHP_EOL; 35} 36 37$zip->close(); 38?> 39--EXPECT-- 40ZipArchive::setArchiveComment(): Argument #1 ($comment) must be less than 65535 bytes 41ZipArchive::setCommentName(): Argument #2 ($comment) must be less than 65535 bytes 42ZipArchive::setCommentIndex(): Argument #2 ($comment) must be less than 65535 bytes 43--CLEAN-- 44<?php 45@unlink(__DIR__ . '/__tmp_oo_set_comment_error.zip'); 46?> 47