#!/usr/bin/env python
#
-# Copyright (C) 2011 W. Trevor King <wking@drexel.edu>
+# Copyright (C) 2011-2012 W. Trevor King <wking@drexel.edu>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
import mailcap as _mailcap
import mimetypes as _mimetypes
+import shlex as _shlex
+if not hasattr(_shlex, 'quote'): # Python < 3.3
+ import pipes as _pipes
+ _shlex.quote = _pipes.quote
import subprocess as _subprocess
if mime is None:
return 1
print('guessed {} for {}'.format(mime, filename))
- match = _mailcap.findmatch(_CAPS, mime, filename=filename)
+ match = _mailcap.findmatch(_CAPS, mime, filename=_shlex.quote(filename))
if match[0] is None:
return 1
print('view {} with {}'.format(filename, match[0]))