$mime = 'application/zip';
$opendocTypes = [
+ # In OASIS Open Document Format v1.2, Database front end document
+ # has a recommended MIME type of:
+ # application/vnd.oasis.opendocument.base
+ # Despite the type registered at the IANA being 'database' which is
+ # supposed to be normative.
+ # T35515
+ 'base',
+
'chart-template',
'chart',
'formula-template',
'text-web',
'text' ];
- // https://lists.oasis-open.org/archives/office/200505/msg00006.html
+ // The list of document types is available in OASIS Open Document
+ // Format version 1.2 under Appendix C. It is not normative though,
+ // supposedly types registered at the IANA should be.
+ // http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html
$types = '(?:' . implode( '|', $opendocTypes ) . ')';
$opendocRegex = "/^mimetype(application\/vnd\.oasis\.opendocument\.$types)/";
$actualType = $this->doGuessMimeType( [ $file, 'doc' ] );
$this->assertEquals( 'application/msword', $actualType );
}
+
+ /**
+ * @covers MimeAnalyzer::detectZipType
+ * @dataProvider provideOpendocumentsformatHeaders
+ */
+ function testDetectZipTypeRecognizesOpendocuments( $expected, $header ) {
+ $this->assertEquals(
+ $expected,
+ $this->mimeAnalyzer->detectZipType( $header )
+ );
+ }
+
+ /**
+ * An ODF file is a ZIP file of multiple files. The first one being
+ * 'mimetype' and is not compressed.
+ */
+ function provideOpendocumentsformatHeaders() {
+ $thirtychars = str_repeat( 0, 30 );
+ return [
+ 'Database front end document header based on ODF 1.2' => [
+ 'application/vnd.oasis.opendocument.base',
+ $thirtychars . 'mimetypeapplication/vnd.oasis.opendocument.basePK',
+ ],
+ ];
+ }
+
}