Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We replace all deprecated libzip functions with their recommended substitutes, and add proper comment length checks including a test case.
- Loading branch information
Showing
3 changed files
with
87 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--TEST-- | ||
setComment error behavior | ||
--SKIPIF-- | ||
<?php | ||
if(!extension_loaded('zip')) die('skip zip extension not available'); | ||
?> | ||
--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'); | ||
?> |