git » sea » commit 2d894b0

When mimetypes can't guess the extension, don't use it

author Alberto Bertogli
2010-05-09 06:34:31 UTC
committer Alberto Bertogli
2010-05-09 06:35:55 UTC
parent acca81a3f471a6c3bd6eabf6d929ee8ac9de563f

When mimetypes can't guess the extension, don't use it

When mimetypes can't guess the extension, we shouldn't attempt to use it.
While at it, also remove the "." because it is included in the returned
string.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>

sea +4 -1

diff --git a/sea b/sea
index 22d14ea..6a5ff08 100755
--- a/sea
+++ b/sea
@@ -55,7 +55,10 @@ def main(infd, basepath):
 		if not fname or "=?" in fname:
 			ext = mimetypes.guess_extension(
 					part.get_content_type() )
-			fname = 'att-%d.%s' % (count, ext)
+			if ext:
+				fname = 'att-%d%s' % (count, ext)
+			else:
+				fname = 'att-%d' % count
 		fname = fname.replace('/', '')
 
 		# since it's not multipart (checked earlier), we know this is