Comment 1 for bug 1101237

Revision history for this message
Gaëtan Delannay (gaetan-delannay) wrote :

Hi Gaël,
Thanks for reporting this bug.
I have committed a fix:

=== modified file 'pod/renderer.py'
--- pod/renderer.py 2012-12-20 15:09:05 +0000
+++ pod/renderer.py 2013-01-22 15:28:41 +0000
@@ -499,14 +499,27 @@
             resultOdt = zipfile.ZipFile(resultOdtName,'w', zipfile.ZIP_DEFLATED)
         except RuntimeError:
             resultOdt = zipfile.ZipFile(resultOdtName,'w')
+ # Insert first the file "mimetype" (uncompressed), in order to be
+ # compliant with the OpenDocument Format specification, section 17.4,
+ # that has a restriction when it comes to zip containers: the file
+ # called "mimetype" must be at the beginning of the zip file, it must be
+ # uncompressed and it must be stored without any additional file
+ # attributes. Else, libraries like "magic", under Linux/Unix, are unable
+ # to detect the correct mimetype for POD results (it simply recognizes
+ # it as a "application/zip" and not a
+ # "application/vnd.oasis.opendocument.text)".
+ resultOdt.write(os.path.join(self.unzipFolder, 'mimetype'),
+ 'mimetype', zipfile.ZIP_STORED)
         for dir, dirnames, filenames in os.walk(self.unzipFolder):
             for f in filenames:
                 folderName = dir[len(self.unzipFolder)+1:]
+ # Ignore file "mimetype" that was already inserted.
+ if (folderName == '') and (f == 'mimetype'): continue
                 resultOdt.write(os.path.join(dir, f),
                                 os.path.join(folderName, f))
             if not dirnames and not filenames:

I have tested it by using, under Linux, the following command on a file re-zipped by pod and it seems to work:
file --mime onlyExpressions.odt
onlyExpressions.odt: application/vnd.oasis.opendocument.text

Could you please test it and see if you consider it to be OK?
If the solution is correct I will publish it in the upcoming Appy 0.8.3.
Cheers
Gaetan