[File] [PATCH] of Magdir/archive for newer Corel Draw; *.cdr *.cdt *.cdrt

Jörg Jenderek joerg.jen.der.ek at gmx.net
Sat Aug 10 01:14:14 UTC 2019


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,
some weeks ago i handled some newer Corel Drawings. I run file command
version 5.37 on such Corel Drawings with name extension cdr, cdt and
cdrt for template. With -k -m Magdir/archive options i get an output
like:

14-CMYKpages2VorschauUmriss.cdr: Zip data (MIME type
		"application/x-vnd.corel.draw.document+zip"?)
15-CMYKpages2VorschauUmriss.cdr: Zip data (MIME type
		"application/x-vnd.corel.draw.document+zip"?)
16-DentistEmbedFontsCMX.cdr:     Zip data (MIME type
		"application/x-vnd.corel.draw.document+zip"?)
17-spray_flowers.cdr:            Zip data (MIME type
		"application/x-vnd.corel.zcf.draw.document+zip"?)
coreldraw2019-v14.cdrt:          Zip data (MIME type
		"application/x-vnd.corel.draw.template+zip"?)
coreldraw2019-v15.cdrt:          Zip data (MIME type
		"application/x-vnd.corel.draw.template+zip"?)
coreldraw2019-v16.3.cdrt:        Zip data (MIME type
		"application/x-vnd.corel.draw.template+zip"?)
coreldraw2019-v17.cdrt:          Zip data (MIME type
		"application/x-vnd.corel.zcf.draw.template+zip"?)
coreldraw2019-v19_2017.cdr:      Zip data (MIME type
		"application/x-vnd.corel.zcf.draw.document+zip"?)
coreldraw2019-v20_2018.cdr:      Zip data (MIME type
		"application/x-vnd.corel.zcf.draw.document+zip"?)
coreldraw2019-v21.cdr:           Zip data (MIME type
		"application/x-vnd.corel.zcf.draw.document+zip"?)
coreldraw2019-v21.cdrt:          Zip data (MIME type
		"application/x-vnd.corel.zcf.draw.template+zip"?)
drawX8.cdr:                      Zip data (MIME type
		"application/x-vnd.corel.zcf.draw.document+zip"?)

Such samples are only recognized as generic ZIP archive with
unrecognized MIME type starting with application/ .

Furthermore with --extension option only ??? is displayed. And with -i
option only application/zip is displayed.

Most information can be found on CorelDraw page on Wikipedia. So i add
a comment line:
 # URL:	http://en.wikipedia.org/wiki/CorelDRAW

According to Wikipedia there exist 3 different file formats for Corel
CDR files. Til version 2 proprietary file format is used that is
recognizable by the first two bytes of the file being "WL" and is not
detected by file command. From Version 3 til 13 the file format
changed to a Resource Interchange File Format (RIFF) container and
partly detected by file command. From version X4 (14) on, the CDR file
is a ZIP-compressed directory of several files, which are handled here
.

So i add in Magdir/archive after EPUB document entry lines for
inspected Corel Draw samples. The mime type start with
"application/x-vnd.corel". This is now detected by magic line
 >>50	string	x-vnd.corel.	 Corel

Afterwards add remaining mime type parts, which are different
depending on version and file type by code segment
 >>>62	string	draw.document+zip	Draw drawing, version 14-16
 !:mime	application/x-vnd.corel.draw.document+zip
 !:ext	cdr
 >>>62	string	draw.template+zip	Draw template, version 14-16
 !:mime	application/x-vnd.corel.draw.template+zip
 !:ext	cdrt
 >>>62	string	zcf.draw.document+zip	Draw drawing, version 17-21
 !:mime	application/x-vnd.corel.zcf.draw.document+zip
 !:ext	cdr
 >>>62	string	zcf.draw.template+zip	Draw template, version 17-21
 !:mime	application/x-vnd.corel.zcf.draw.template+zip
 !:ext	cdt/cdrt

At this point the message starting with phrase "Zip data (MIME type"
still appears, because the branch to handle remaining unrecognized ZIP
archives with mime type starting with "application/" are done in a
specific way. That is is to exclude all ZIP archives with known mime
type and then displaying mentioned phrase part. This looks like:
 >>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"?)

Of course i can add an additional line before regex expression to
exclude Corel Draw like
 >>>>>>50	string	!x-vnd.corel.

Instead i use another way. After handling ZIP archives with known
mime types match the remaining unrecognized by "default" test. This
now looks:
 >>50		default	x			Zip data
 >>>38		regex	[!-OQ-~]+		(MIME type "%s"?)

After applying the above mentioned modifications by patch
file-5.37-archive-coreldraw.diff then i get a more precise output like
:
14-CMYKpages2VorschauUmriss.cdr: Corel Draw drawing, version 14-16
15-CMYKpages2VorschauUmriss.cdr: Corel Draw drawing, version 14-16
16-DentistEmbedFontsCMX.cdr:     Corel Draw drawing, version 14-16
17-spray_flowers.cdr:            Corel Draw drawing, version 17-21
coreldraw2019-v14.cdrt:          Corel Draw template,
				 version 14-16
coreldraw2019-v15.cdrt:          Corel Draw template,
				 version 14-16
coreldraw2019-v16.3.cdrt:        Corel Draw template,
				 version 14-16
coreldraw2019-v17.cdrt:          Corel Draw template,
				 version 17-21
coreldraw2019-v19_2017.cdr:      Corel Draw drawing, version 17-21
coreldraw2019-v20_2018.cdr:      Corel Draw drawing, version 17-21
coreldraw2019-v21.cdr:           Corel Draw drawing, version 17-21
coreldraw2019-v21.cdrt:          Corel Draw template,
				 version 17-21
drawX8.cdr:                      Corel Draw drawing, version 17-21



I hope my diff file can be applied in future version of
file utility.

With best wishes
Jörg Jenderek
- --
Jörg Jenderek















-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iF0EARECAB0WIQS5/qNWKD4ASGOJGL+v8rHJQhrU1gUCXU4aWwAKCRCv8rHJQhrU
1qY9AJ9jDnUJSjCgUCIZN/smCXS9Ek4jTgCZAdQPlBv1oKoM7cppWJUqeLdcztE=
=iNl1
-----END PGP SIGNATURE-----
-------------- next part --------------
--- file-5.37/magic/Magdir/archive.old	2019-05-09 18:58:02 +0000
+++ file-5.37/magic/Magdir/archive	2019-08-10 01:06:51 +0000
@@ -1168,17 +1168,31 @@
 >>50	string	epub+zip	EPUB document
 !:mime application/epub+zip
 
+# From:	Joerg Jenderek
+# URL:	http://en.wikipedia.org/wiki/CorelDRAW
+# NOTE:	version; til 2 WL-based; from 3 til 13 by ./riff; from 14 zip based
+>>50	string	x-vnd.corel.	 Corel
+>>>62	string	draw.document+zip	Draw drawing, version 14-16
+!:mime	application/x-vnd.corel.draw.document+zip
+!:ext	cdr
+>>>62	string	draw.template+zip	Draw template, version 14-16
+!:mime	application/x-vnd.corel.draw.template+zip
+!:ext	cdrt
+>>>62	string	zcf.draw.document+zip	Draw drawing, version 17-21
+!:mime	application/x-vnd.corel.zcf.draw.document+zip
+!:ext	cdr
+>>>62	string	zcf.draw.template+zip	Draw template, version 17-21
+!:mime	application/x-vnd.corel.zcf.draw.template+zip
+!:ext	cdt/cdrt
+
 #  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"?)
+>>50		default	x			Zip data
+>>>38		regex	[!-OQ-~]+		(MIME type "%s"?)
 !:mime	application/zip
 #    (mimetype contents other than "application/*")
 >26		string	\x8\0\0\0mimetype
-------------- next part --------------
A non-text attachment was scrubbed...
Name: file-5.37-archive-coreldraw.diff.sig
Type: application/octet-stream
Size: 95 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20190810/8da4c94f/attachment.obj>


More information about the File mailing list