1 2#------------------------------------------------------------------------------ 3# $File: msooxml,v 1.3 2013/09/12 16:08:07 christos Exp $ 4# msooxml: file(1) magic for Microsoft Office XML 5# From: Ralf Brown <ralf.brown@gmail.com> 6 7# .docx, .pptx, and .xlsx are XML plus other files inside a ZIP 8# archive. The first member file is normally "[Content_Types].xml". 9# but some libreoffice generated files put this later. Perhaps skip 10# the "[Content_Types].xml" test? 11# Since MSOOXML doesn't have anything like the uncompressed "mimetype" 12# file of ePub or OpenDocument, we'll have to scan for a filename 13# which can distinguish between the three types 14 15# start by checking for ZIP local file header signature 160 string PK\003\004 17!:strength +10 18# make sure the first file is correct 19>0x1E string [Content_Types].xml 20>>0 use msooxml 21>0xE84 string [Content_Types].xml 22>>0 use msooxml 23 240 name msooxml 25# skip to the second local file header 26# since some documents include a 520-byte extra field following the file 27# header, we need to scan for the next header 28>(18.l+49) search/2000 PK\003\004 29# now skip to the *third* local file header; again, we need to scan due to a 30# 520-byte extra field following the file header 31>>&26 search/1000 PK\003\004 32# and check the subdirectory name to determine which type of OOXML 33# file we have. Correct the mimetype with the registered ones: 34# http://technet.microsoft.com/en-us/library/cc179224.aspx 35>>>&26 string word/ Microsoft Word 2007+ 36!:mime application/vnd.openxmlformats-officedocument.wordprocessingml.document 37>>>&26 string ppt/ Microsoft PowerPoint 2007+ 38!:mime application/vnd.openxmlformats-officedocument.presentationml.presentation 39>>>&26 string xl/ Microsoft Excel 2007+ 40!:mime application/vnd.openxmlformats-officedocument.spreadsheetml.sheet 41>>>&26 default x Microsoft OOXML 42