Better detection for old MS Office files
authorTim Starling <tstarling@wikimedia.org>
Tue, 15 Jan 2019 03:15:18 +0000 (14:15 +1100)
committerTim Starling <tstarling@wikimedia.org>
Tue, 22 Jan 2019 22:23:17 +0000 (09:23 +1100)
commitf12db3804882272794b4dafc72db1c5d787375bf
tree4665ce6fae69b40f26fbc7e0e1487c75727b8a6d
parentca8678e23815a6fe8e71e897b4654cbd17a4447d
Better detection for old MS Office files

* Introduce MSCompoundFileReader, which reads the CFB directory and
  detects the file type from well-known names in the root directory
* Do not detect a ZIP file if the EOCDR is not at the end. Other
  containers, especially CFB files, may contain ZIP files embedded
  within them in the last 64KB, but this is not a security concern
  unless the EOCDR is exactly at the end of the file.

Bug: T40432
Change-Id: Id5b1a258ccf3c3c8951e32f6b7a5b1bafe941082
18 files changed:
autoload.php
includes/libs/mime/MSCompoundFileReader.php [new file with mode: 0644]
includes/libs/mime/MimeAnalyzer.php
includes/utils/ZipDirectoryReader.php
tests/phpunit/data/MSCompoundFileReader/calc.xls [new file with mode: 0644]
tests/phpunit/data/MSCompoundFileReader/dir-beyond-end.xls [new file with mode: 0644]
tests/phpunit/data/MSCompoundFileReader/excel2016-compat97.xls [new file with mode: 0755]
tests/phpunit/data/MSCompoundFileReader/fat-loop.xls [new file with mode: 0644]
tests/phpunit/data/MSCompoundFileReader/gnumeric.xls [new file with mode: 0644]
tests/phpunit/data/MSCompoundFileReader/impress.ppt [new file with mode: 0644]
tests/phpunit/data/MSCompoundFileReader/invalid-signature.xls [new file with mode: 0644]
tests/phpunit/data/MSCompoundFileReader/powerpoint2016-compat97.ppt [new file with mode: 0755]
tests/phpunit/data/MSCompoundFileReader/word2016-compat97.doc [new file with mode: 0755]
tests/phpunit/data/MSCompoundFileReader/writer.doc [new file with mode: 0644]
tests/phpunit/data/media/zip-in-doc.doc [new file with mode: 0644]
tests/phpunit/includes/libs/mime/MSCompoundFileReaderTest.php [new file with mode: 0644]
tests/phpunit/includes/libs/mime/MimeAnalyzerTest.php
tests/phpunit/includes/utils/ZipDirectoryReaderTest.php