From:             dani dot church at gmail dot com
Operating system: CentOS 5
PHP version:      5.2CVS-2009-07-01 (snap)
PHP Bug Type:     Zip Related
Bug description:  ZipArchive produces corrupt OpenOffice.org files

Description:
------------
When PHP writes a .od* file using ZipArchive, the resulting archive cannot
be opened by OpenOffice.org.  The error it gives is "The file 'filename' is
corrupt and therefore cannot be opened.  Should OpenOffice.org repair the
file?"

Repairing the file in OO.o does not work.  However, unzipping the file
from the command line (using unzip in OSX) works without error, and unzip
-t (test integrity) reports no errors.  Furthermore, the extracted files
are byte-correct, and zipping the extracted files into a new .od* file
results in a valid OpenOffice.org file.

This bug is a regression since 5.2.6.  Using zip.so from 5.2.6 results in
a valid file.  Using zip.so from 5.2CVS-2009-07-01 results in a corrupt
file.

Reproduce code:
---------------
<?php
if (isset($_FILES['od'])) {
  $odfile = $_FILES['od']['tmp_name'];
  $zip = new ZipArchive();
  $zip->open($odfile);
  $xml = $zip->getFromName('content.xml');
  $zip->addFromString('content.xml', $xml);
  $zip->close();
  header('content-type: application/vnd.oasis.opendocument.spreadsheet');
  header('content-disposition: attachment;filename=test.ods');
  readfile($odfile);
  unlink($odfile);
  return;
}
?>
<form method="POST" enctype="multipart/form-data">
<input type='file' name='od'
<input type='submit'>
</form>

Expected result:
----------------
Using the above testbed (for ODS spreadsheets) to update content.xml with
its own data should result in a valid ODS spreadsheet.

Actual result:
--------------
The resulting spreadsheet is corrupt and cannot be opened.

-- 
Edit bug report at http://bugs.php.net/?id=48763&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=48763&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=48763&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=48763&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=48763&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=48763&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=48763&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=48763&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=48763&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=48763&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=48763&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=48763&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=48763&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=48763&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=48763&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=48763&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=48763&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=48763&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=48763&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=48763&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=48763&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=48763&r=mysqlcfg

Reply via email to