brianmario/charlock_holmes — pull request #28 by arthurschreiber (2013-02-17 01:55:48+00:00)
Title: Fix detection for TCL (and possibly other file types).

This changes how binary files are detected.

Previously, libmagic was used to get the magic message for a file's
contents and check if the message contained the substring "text". This
worked fine for most file types, but some magic messages did not
contain this substring (e.g. for TCL files, it was only `Tcl script, `)
and they'd incorrectly be detected as binary (see
brianmario/charlock_holmes#13).

This commit sets the magic `MAGIC_MIME` flag so that `magic_buffer` instead returns the
mime type, and we now check if that mime type contains the substring
`charset=binary`.