fixed GH #2188: handle directory entries stored with DEFLATE compression method

This commit is contained in:
Günter Obiltschnig 2018-03-06 12:44:40 +01:00
parent 20f9320f2d
commit 27dc684d77
3 changed files with 9 additions and 2 deletions

View File

@ -300,7 +300,7 @@ inline bool ZipFileInfo::isFile() const
inline bool ZipFileInfo::isDirectory() const
{
poco_assert_dbg(!_fileName.empty());
return getUncompressedSize() == 0 && getCompressionMethod() == ZipCommon::CM_STORE && _fileName[_fileName.length()-1] == '/';
return getUncompressedSize() == 0 && _fileName[_fileName.length()-1] == '/';
}

View File

@ -464,7 +464,7 @@ inline bool ZipLocalFileHeader::isFile() const
inline bool ZipLocalFileHeader::isDirectory() const
{
poco_assert_dbg(!_fileName.empty());
return getUncompressedSize() == 0 && getCompressionMethod() == ZipCommon::CM_STORE && _fileName[_fileName.length()-1] == '/';
return getUncompressedSize() == 0 && _fileName[_fileName.length()-1] == '/';
}

View File

@ -86,6 +86,13 @@ bool Decompress::handleZipEntry(std::istream& zipStream, const ZipLocalFileHeade
Poco::File aFile(dir);
aFile.createDirectories();
}
if (hdr.getCompressionMethod() == ZipCommon::CM_DEFLATE)
{
// If directory is stored with deflate method, two extra bytes
// (the result of deflating a zero-length sequence) must be read.
char buffer[2];
zipStream.read(buffer, 2);
}
return true;
}
try