Make the mimetype detection safe