From 1ac7dc9b33669675835c73ab4918830883a06f45 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Mon, 28 May 2012 08:11:51 +0200 Subject: [PATCH] Properly handle extension-less files --- parse | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parse b/parse index 93ec4ad..5930c93 100755 --- a/parse +++ b/parse @@ -144,9 +144,9 @@ for email_file in file_list: attachment_sha1 = hashlib.sha1(attachment_data).hexdigest() attachment_filename = part.get_filename() attachment_type = part.get_content_type() - attachment_extension = os.path.splitext(attachment_filename)[1][1:] + attachment_extension = os.path.splitext(attachment_filename)[1] attachment_size = len(attachment_data) - attachment_destination = "%s/%s.%s" % (options['attachment_dir'], attachment_sha1, attachment_extension) + attachment_destination = "%s/%s%s" % (options['attachment_dir'], attachment_sha1, attachment_extension) attachment_list.append((attachment_filename, attachment_type, attachment_sha1, attachment_size)) attachment_file = open(attachment_destination, "w")