Gemorroj / Archive7z

This library provides handling of 7z files in PHP
GNU Lesser General Public License v3.0
89 stars 20 forks source link

getCrc() fails sometimes #30

Open wapmorgan opened 2 years ago

wapmorgan commented 2 years ago

For few archive types, CRC is not parsed from 7z l, so it is empty, so it fails with Exception

Fatal error: Uncaught TypeError: Archive7z\Entry::getCrc(): Return value must be of type string, null returned in /app/vendor/gemorroj/archive7z/src/Entry.php:240
Stack trace:
#0 /app/src/Drivers/SevenZip.php(217): Archive7z\Entry->getCrc()
#1 /app/src/UnifiedArchive.php(284): wapmorgan\UnifiedArchive\Drivers\SevenZip->getFileData('doc')
#2 /app/src/Commands/TableCommand.php(66): wapmorgan\UnifiedArchive\UnifiedArchive->getFileData('doc')

I found that crc is present for ZIP/TAR.GZ, and not present for TAR

wapmorgan commented 2 years ago

And for ISO files there's another problem: Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /app/vendor/gemorroj/archive7z/src/Entry.php on line 189. Output of /usr/bin/7z command 7zl.txt attached

wapmorgan commented 2 years ago

And even empty Path:

TypeError: Archive7z\Entry::getPath(): Return value must be of type string, null returned

/app/vendor/gemorroj/archive7z/src/Entry.php:278
/app/vendor/gemorroj/archive7z/src/Entry.php:283
/app/src/Drivers/SevenZip.php:171
/app/tests/DriversTest.php:110

for listing file https://github.com/wapmorgan/UnifiedArchive/releases/download/0.0.1/onefile.xz

Gemorroj commented 2 years ago

@wapmorgan tnx. i have fixed some problems except empty path in xz archive. i will think about how to fix it.