summaryrefslogtreecommitdiff
path: root/alot/helper.py
diff options
context:
space:
mode:
authorYann Rouillard <yann@pleiades.fr.eu.org>2013-06-28 23:45:12 +0200
committerPatrick Totzke <patricktotzke@gmail.com>2013-07-18 09:38:28 +0100
commit045ccff05175de053b469870fe76ee5a60fdf65b (patch)
tree4a455b8aed25945582ceca30167753a9821ad8b9 /alot/helper.py
parentd093628919b35ee5dda77ca1e4f4e4f951259fd3 (diff)
add a rough check on the libmagic library version for the libmagic bug workaround
Diffstat (limited to 'alot/helper.py')
-rw-r--r--alot/helper.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/alot/helper.py b/alot/helper.py
index 9ae53999..662cb3b9 100644
--- a/alot/helper.py
+++ b/alot/helper.py
@@ -445,8 +445,12 @@ def mimewrap(path, filename=None, ctype=None):
# libmagic < 5.12 incorrectly detects excel/powerpoint files as
# 'application/msword' (see #179 and #186 in libmagic bugtracker)
# This is a workaround, based on file extension, useful as long
- # as distributions still ship libmagic 5.11
- if ctype == 'application/msword':
+ # as distributions still ship libmagic 5.11.
+ # To see if we must apply the workaround, we just check the
+ # availability of the magic_version function which has been
+ # introduced in libmagic 5.13
+ if (not hasattr(magic._libraries['magic'], 'magic_version') and
+ ctype == 'application/msword'):
mimetype, encoding = mimetypes.guess_type(path)
if mimetype:
ctype = mimetype