Bug #66445 [Fbk->Opn]: ZipArchive doesn't set external file attributes

From: Date: Fri, 10 Jan 2014 12:14:46 +0000
Subject: Bug #66445 [Fbk->Opn]: ZipArchive doesn't set external file attributes
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-183691@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66445&edit=1

 ID:                 66445
 User updated by:    cmbecker69 at gmx dot de
 Reported by:        cmbecker69 at gmx dot de
 Summary:            ZipArchive doesn't set external file attributes
-Status:             Feedback
+Status:             Open
 Type:               Bug
 Package:            Zip Related
 Operating System:   Windows
 PHP Version:        5.5.7
 Block user comment: N
 Private report:     N

 New Comment:

For automated testing it might be sufficient to scan the zip file
for central file header signatures (section 4.3.12 of the PKWARE
specification) and inspect the first byte of the external file 
attributes.  Telling files and directories apart seems to be harder
in the general case.  Assuming there are no empty files in the 
archive, it would suffice to check for the (un)compressed size.
Alternatively, one might check the last character of the file name,
assuming all directory names are stored with a trailing slash.


Previous Comments:
------------------------------------------------------------------------
[2014-01-10 07:42:05] ab@php.net

libzip is the one responsible for that.

Btw. how do you check that programmatically? Looks impossible, as one would need to reparse the
whole file manually.

------------------------------------------------------------------------
[2014-01-08 21:00:37] cmbecker69 at gmx dot de

Description:
------------
The ZipArchive class doesn't set the external file attributes,
what is a particular problem regarding directories which are 
displayed as files in Windows XP's explorer (works fine in Win 7,
though; can't tests other Windows versions).

According to the PKWARE Zip specification[1], section 4.4.15:

| The mapping of the external attributes is
| host-system dependent (see 'version made by').  For
| MS-DOS, the low order byte is the MS-DOS directory
| attribute byte.

The "version made by" field in the created ZIP file is 0, what 
signals MSDOS, but the low order byte of the "external file 
attributes" field is always 0 (should be 0x10 for directories). 

[1] <http://www.pkware.com/documents/casestudies/APPNOTE.TXT>

Test script:
---------------
$zip = new ZipArchive();
$zip->open('foo.zip', ZipArchive::CREATE);
$zip->addEmptyDir('bar');
$zip->close();


Expected result:
----------------
A ZIP file conforming to the PKWARE specification is created.

Actual result:
--------------
The created ZIP file doesn't conform to the PKWARE specification.


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=66445&edit=1


Thread (7 messages)

« previous php.bugs (#183691) next »