fixes from cchittleborough+comp.file@cluemail.com ("Christopher Chittleborough")
authorChristos Zoulas <christos@zoulas.com>
Tue, 26 Oct 2010 14:08:47 +0000 (14:08 +0000)
committerChristos Zoulas <christos@zoulas.com>
Tue, 26 Oct 2010 14:08:47 +0000 (14:08 +0000)
magic/Magdir/archive

index 95cdb9c0fdde55f5dc52321c38787c1a64baf0b7..2411b29d66a2d37b0fa36692554e501e6b7b1702 100644 (file)
@@ -1,5 +1,5 @@
 #------------------------------------------------------------------------------
-# $File: archive,v 1.58 2010/09/20 19:19:16 rrt Exp $
+# $File: archive,v 1.59 2010/10/25 22:48:38 christos Exp $
 # archive:  file(1) magic for archive formats (see also "msdos" for self-
 #           extracting compressed archives)
 #
 # Splint
 0      string  \x93\xb9\x06 Splint archive data
 # InstallShield
-0      string   \x13\x5d\x65\x8c InstallShield Z archive Data
+0      string  \x13\x5d\x65\x8c InstallShield Z archive Data
 # Gather
 1      string  GTH Gather archive data
 # BOA
 0      string          HPAK            HPACK archive data
 
 # JAM Archive volume format, by Dmitry.Kohmanyuk@UA.net
-0      string          \351,\001JAM\           JAM archive,
+0      string          \351,\001JAM\           JAM archive,
 >7     string          >\0                     version %.4s
 >0x26  byte            =0x27                   -
 >>0x2b string          >\0                     label %.11s,
 # Zip archives (Greg Roelofs, c/o zip-bugs@wkuvx1.wku.edu)
 0      string          PK\003\004
 
-# Specialised zip formats
->30    string          mimetype
+# Specialised zip formats which start with a member named 'mimetype'
+# (stored uncompressed, with no 'extra field') containing the file's MIME type.
+# Check for have 8-byte name, 0-byte extra field, name "mimetype", and
+#  contents starting with "application/":
+>26    string          \x8\0\0\0mimetypeapplication/
 
-# OpenOffice.org / KOffice / StarOffice documents
-# From: Abel Cheung <abel@oaka.org>
+#  KOffice / OpenOffice & StarOffice / OpenDocument formats
+#    From: Abel Cheung <abel@oaka.org>
 
-# KOffice (1.2 or above) formats
+#   KOffice (1.2 or above) formats
+#    (mimetype contains "application/vnd.kde.<SUBTYPE>")
 >>50   string  vnd.kde.                KOffice (>=1.2)
 >>>58  string  karbon                  Karbon document
 >>>58  string  kchart                  KChart document
 >>>58  string  kspread                 KSpread document
 >>>58  string  kword                   KWord document
 
-# OpenOffice formats (for OpenOffice 1.x / StarOffice 6/7)
-#  mimetype contains 'application/vnd.sun.xml.<SUBTYPE>'
+#   OpenOffice formats (for OpenOffice 1.x / StarOffice 6/7)
+#    (mimetype contains "application/vnd.sun.xml.<SUBTYPE>")
 >>50   string  vnd.sun.xml.            OpenOffice.org 1.x
 >>>62  string  writer                  Writer
 >>>>68 byte    !0x2e                   document
 >>>62  string  math                    Math document
 >>>62  string  base                    Database file
 
-# OpenDocument formats (for OpenOffice 2.x / StarOffice >= 8)
-# http://lists.oasis-open.org/archives/office/200505/msg00006.html
-#  mimetype contains 'application/vnd.oasis.opendocument.<SUBTYPE>'
+#   OpenDocument formats (for OpenOffice 2.x / StarOffice >= 8)
+#    http://lists.oasis-open.org/archives/office/200505/msg00006.html
+#    (mimetype contains "application/vnd.oasis.opendocument.<SUBTYPE>")
 >>50   string  vnd.oasis.opendocument. OpenDocument
 >>>73  string  text
 >>>>77 byte    !0x2d                   Text
 >>>>78 string  -template               Template
 !:mime application/vnd.oasis.opendocument.image-template
 
-# OEBPS Container Format (OCF) 1.0
->>50   string  epub+zip                OEBPS Container Format (OCF) 1.0 (EPUB)
+#  EPUB (OEBPS) books using OCF (OEBPS Container Format)
+#    From: Adam Buchbinder <adam.buchbinder@gmail.com>
+#    http://www.idpf.org/ocf/ocf1.0/download/ocf10.htm, section 4.
+#    (mimetype contains "application/epub+zip")
+>>50   string  epub+zip                EPUB ebook data
 !:mime application/epub+zip
 
-# Generic zip archives (Greg Roelofs, c/o zip-bugs@wkuvx1.wku.edu)
-# N.B. Must come after specialised formats
-# Next line simply matches anything, including "mimetype" as used above
->30    byte            x
->>4    byte            0x00            Zip archive data
-!:mime application/zip
->>4    byte            0x09            Zip archive data, at least v0.9 to extract
-!:mime application/zip
->>4    byte            0x0a            Zip archive data, at least v1.0 to extract
+#  Catch other ZIP-with-mimetype formats
+#      In a ZIP file, the bytes immediately after a member's contents are
+#      always "PK". The 2 regex rules here print the "mimetype" member's
+#      contents up to the first 'P'. Luckily, most MIME types don't contain
+#      any capital 'P's. This is a kludge.
+#    (mimetype contains "application/<OTHER>")
+>>50           string  !epub+zip
+>>>50          string  !vnd.oasis.opendocument.
+>>>>50         string  !vnd.sun.xml.
+>>>>>50                string  !vnd.kde.
+>>>>>>38       regex   [!-OQ-~]+               Zip data (MIME type "%s"?)
 !:mime application/zip
->>4    byte            0x0b            Zip archive data, at least v1.1 to extract
+#    (mimetype contents other than "application/*")
+>26            string  \x8\0\0\0mimetype
+>>38           string  !application/
+>>>38          regex   [!-OQ-~]+               Zip data (MIME type "%s"?)
 !:mime application/zip
->>0x161        string          WINZIP          Zip archive data, WinZIP self-extracting
-!:mime application/zip
->>4    byte            0x14            Zip archive data, at least v2.0 to extract
-!:mime application/zip
-
-# EPUB (OEBPS) books using OCF (Open Container Format)
-# From: Adam Buchbinder <adam.buchbinder@gmail.com>
-# URL: http://www.idpf.org/ocf/ocf1.0/download/ocf10.htm, section 4.
->>38   string  application/epub+zip    EPUB ebook
-!:mime application/epub+zip
-
-# EPUB documents (.epub eBooks) are also zip archives starting with a
-# 'mimetype' member, which contains 'application/epub+zip'.
->>50   string          epub+zip        epub eBook data
-!:mime application/epub+zip
-
-# Catch other ZIP-with-mimetype formats
->>50           string          !epub+zip
->>>50          string          !vnd.oasis.opendocument.
->>>>50         string          !vnd.sun.xml.
->>>>>50                string          !vnd.kde.
->>>>>>38       regex           [!-OQ-~]+       Zip data (mimetype "%s"?)
->26    string          \x8\0\0\0mimetype
->>38   string          !application/
->>>38  regex           [!-OQ-~]+               Zip data (mimetype "%s"?)
 
+# Generic zip archives (Greg Roelofs, c/o zip-bugs@wkuvx1.wku.edu)
+#   Next line excludes specialized formats:
+>26    string          !\x8\0\0\0mimetype      Zip archive data
+!:mime application/zip
+>>4    byte            0x09            \b, at least v0.9 to extract
+>>4    byte            0x0a            \b, at least v1.0 to extract
+>>4    byte            0x0b            \b, at least v1.1 to extract
+>>0x161        string          WINZIP          \b, WinZIP self-extracting
+>>4    byte            0x14            \b, at least v2.0 to extract
 
 # Zoo archiver
 20     lelong          0xfdc4a7dc      Zoo archive data
 
 # GTKtalog catalogs
 # by David Necas (Yeti) <yeti@physics.muni.cz>
-4      string  gtktalog\       GTKtalog catalog data,
+4      string  gtktalog\       GTKtalog catalog data,
 >13    string  3               version 3
 >>14   beshort 0x677a          (gzipped)
 >>14   beshort !0x677a         (not gzipped)
 !:mime application/x-bittorrent
 
 # Atari MSA archive - Teemu Hukkanen <tjhukkan@iki.fi>
-0       beshort 0x0e0f          Atari MSA archive data
->2      beshort x               \b, %d sectors per track
->4      beshort 0               \b, 1 sided
->4      beshort 1               \b, 2 sided
->6      beshort x               \b, starting track: %d
->8      beshort x               \b, ending track: %d
+0      beshort 0x0e0f          Atari MSA archive data
+>2     beshort x               \b, %d sectors per track
+>4     beshort 0               \b, 1 sided
+>4     beshort 1               \b, 2 sided
+>6     beshort x               \b, starting track: %d
+>8     beshort x               \b, ending track: %d
 
 # Alternate ZIP string (amc@arwen.cs.berkeley.edu)
 0      string  PK00PK\003\004  Zip archive data
 >>0x2A string  >\0             : %s
 
 # DR-DOS 7.03 Packed File *.??_
-0      string  Packed\ File\   Personal NetWare Packed File
->12    string  x               \b, was "%.12s"
+0      string  Packed\ File\   Personal NetWare Packed File
+>12    string  x               \b, was "%.12s"
 
 # EET archive
 # From: Tilman Sauerbeck <tilman@code-monkey.de>