[File] [PATCH] of Magdir/macintosh,uuencode for BinHex binary; *.hqx
Jörg Jenderek
joerg.jen.der.ek at gmx.net
Sat Dec 14 14:26:07 UTC 2019
Hello,
some days ago i handled some BinHex binaries. When searching on my
systems and the internet for such files and similar test files and
running file command version 5.37 with -k option i get unexpected
output like:
mac-update-40b7.hqx: news or mail, ASCII text
MACDEV6B.HQX: BinHex binary text, version 4.0\012-
BinHex binary text, version 4.0, ASCII text
RESRC_DE.HQX: ASCII text
shrinkwrap-21.hqx: BinHex binary text, version 4.0\012-
BinHex binary text, version 4.0, ASCII text
zap-res-forks-101.hqx: data
Furthermore with --extension only ??? is displayed.
First of all i get duplicate messages. One is triggered by line
inside Magdir/macintosh looking like:
11 string must\ be\ converted\ with\ BinHex BinHex binary text
The other message is triggered by nearly same magic inside
Magdir/uuencode looking like
11 search/1 must\ be\ converted\ with\ BinHex BinHex binary text
Most information about this file format ca be found on Wikipedia. So
i add a comment line like
# URL: https://en.wikipedia.org/wiki/BinHex
According to documentations the characteristic magic for BinHex is a
sentence starting like:
(This file must be converted with BinHex
For most inspected examples this sentence is found at offset 0 of
file. But sometimes one empty line is before the sentence. This
should be matched only by magic inside Magdir/uuencode. And according
to RFC 1741 any text before this magic sentence is to be ignored. So
there exist samples with text consisting of thousand characters
before magic sentence like in mac-update-40b7.hqx found on
ftp.vim.org. So search range must be raised.
Furthermore another error occurs. The "string" and "search" directive
used at the moment only works for text files and not binary
considered files. So examples like zap-res-forks-101.hqx also found
on ftp.vim.org are described by file command only as "binary" data.
When looking in that file i find control-characters like ^C and a
copyright symbol like ©. So this file is not ASCII text and must be
handled as binary. The magic test lines now become like
0 search/1602 (This\ file\
>&0 use binhex
0 search/2652/b (This\ file\
>&0 use binhex
0 name binhex
>0 string must\ be\ converted\ with\ BinHex\ BinHex binary text
The first search directive is for ASCII text samples and the second
is for binary branch.
Now afterwards show apple type according to web site www.macdisk.com
by line
!:apple BNHQTEXT
At the end of the sentence the version is stored. This is shown
at the moment in current magic files by lines
>41 string x \b, version %.3s
The documentation mainly mentions version 4.0 and i only found test
examples with version 4.0 and hqx extension. But according to
www.faqs.org and Wikipedia for other versions different file name
extensions and maybe different mime types are used, but the
description are not so precisely. I have done my best. Maybe an
BinHex expert should check this. So depending on version this is now
described by
>>&0 string 1.0 1.0
!:mime application/mac-binhex
!:ext hex
>>&0 string 2.0 2.0
!:mime application/mac-binhex
!:ext hcx
>>&0 string 4.0 4.0
!:mime application/mac-binhex40
!:ext hqx
>>&0 string 5.0 5.0
!:mime application/mac-binhex40
!:ext hqx
>>&0 default x
>>>&0 string x %.3s
!:mime application/mac-binhex
!:ext hqx
After applying the above mentioned modifications by patches
file-5.37-uuencode-macbin.diff and file-5.37-macintosh-macbin.diff
the duplicate messages vanish. Further more now cases with garbage
before magic sentence and binary looking files are also recognised
and i get an output like:
mac-update-40b7.hqx: news or mail text
BinHex binary text, version 4.0, ASCII text
MACDEV6B.HQX: BinHex binary text, version 4.0, ASCII text
RESRC_DE.HQX: BinHex binary text, version 4.0, ASCII text
shrinkwrap-21.hqx: BinHex binary text, version 4.0, ASCII text
zap-res-forks-101.hqx: BinHex binary text, version 4.0\012- data
I hope my diff files can be applied in a future version of
file utility.
With best wishes
Jörg Jenderek
--
Jörg Jenderek
-------------- next part --------------
--- file-5.37/magic/Magdir/uuencode.old 2019-02-22 12:06:34 +0000
+++ file-5.37/magic/Magdir/uuencode 2019-12-14 13:52:50 +0000
@@ -23,9 +23,4 @@
# Greg Roelofs, newt at uchicago.edu
0 search/1 Decode\ the\ following\ with\ bdeco bencoded News text
-# BinHex is the Macintosh ASCII-encoded file format (see also "apple")
-# Daniel Quinlan, quinlan at yggdrasil.com
-11 search/1 must\ be\ converted\ with\ BinHex BinHex binary text
->41 search/1 x \b, version %.3s
-
# GRR: handle BASE64
-------------- next part --------------
--- file-5.37/magic/Magdir/macintosh.old 2019-04-19 00:42:27 +0000
+++ file-5.37/magic/Magdir/macintosh 2019-12-14 14:13:11 +0000
@@ -7,5 +7,38 @@
# Daniel Quinlan, quinlan at yggdrasil.com
-11 string must\ be\ converted\ with\ BinHex BinHex binary text
+# Update: Joerg Jenderek
+# URL: https://en.wikipedia.org/wiki/BinHex
+# Reference: http://fileformats.archiveteam.org/wiki/BinHex
+# Note: only tested with version 4.0 and hqx extension
+# Any text/binary before the characteristic comment sentence is to be ignored like in
+# http://ftp.vim.org/pub/ftp/ftp/infomac/disk/mac-update-40b7.hqx
+0 search/1602 (This\ file\
+>&0 use binhex
+# http://ftp.vim.org/pub/ftp/ftp/infomac/_Disk_&_File/zap-res-forks-101.hqx
+0 search/2652/b (This\ file\
+>&0 use binhex
+0 name binhex
+# keep splitted search string format similar like in version 5.37
+>0 string must\ be\ converted\ with\ BinHex\ BinHex binary text, version
+# http://www.macdisk.com/binhexen.php3
+!:apple BNHQTEXT
+# http://www.faqs.org/faqs/macintosh/comm-faq/part1/
+>>&0 string 1.0 1.0
+!:mime application/mac-binhex
+!:ext hex
+>>&0 string 2.0 2.0
+!:mime application/mac-binhex
+!:ext hcx
+# BinHex 3.0 never existed
+>>&0 string 4.0 4.0
!:mime application/mac-binhex40
->41 string x \b, version %.3s
+!:ext hqx
+# BinHex 5.0 also MacBinary I
+>>&0 string 5.0 5.0
+!:mime application/mac-binhex40
+!:ext hqx
+# this should never happen
+>>&0 default x
+>>>&0 string x %.3s
+!:mime application/mac-binhex
+!:ext hqx
More information about the File
mailing list