Fixed #a5d (use basename() on attachment filenames)
authorDmitriy Morozov <dmitriy@mrzv.org>
Thu, 28 Apr 2011 08:50:31 -0700
changeset 68 88c088722a30
parent 67 50ecb341130d
child 69 06875c471689
Fixed #a5d (use basename() on attachment filenames)
.issues/a5d5a0aae0cb2468/new/1276151607.M152689P10154Q1.tomas
.issues/a5d5a0aae0cb2468/new/1304004853.M131867P15337Q1.vine
.issues/a5d5a0aae0cb2468/new/1304005695.M962593P16333Q1.vine
.issues/a5d5a0aae0cb2468/new/1304005796.M468142P16360Q1.vine
artemis/artemis.py
--- a/.issues/a5d5a0aae0cb2468/new/1276151607.M152689P10154Q1.tomas	Thu Apr 28 08:32:55 2011 -0700
+++ b/.issues/a5d5a0aae0cb2468/new/1276151607.M152689P10154Q1.tomas	Thu Apr 28 08:50:31 2011 -0700
@@ -1,8 +1,9 @@
 From: "Tomas Zeman <tzeman@volny.cz>"
 Date: Thu, 10 Jun 2010 08:31:23 +0200
-State: new
+State: resolved
 Subject: Attachments should be stored without path
 Message-Id: <a5d5a0aae0cb2468-0-artemis@tomas>
+resolution: fixed
 
 Attachments are stored with their path causing attachment extract operation to
 override the original file.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.issues/a5d5a0aae0cb2468/new/1304004853.M131867P15337Q1.vine	Thu Apr 28 08:50:31 2011 -0700
@@ -0,0 +1,7 @@
+From: Dmitriy Morozov <dmitriy@mrzv.org>
+Date: Thu, 28 Apr 2011 08:34:13 -0700
+Subject: changed properties (state=in-progress)
+Message-Id: <a5d5a0aae0cb2468-d0ba83355a9b1271-artemis@vine>
+References: <a5d5a0aae0cb2468-0-artemis@tomas>
+In-Reply-To: <a5d5a0aae0cb2468-0-artemis@tomas>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.issues/a5d5a0aae0cb2468/new/1304005695.M962593P16333Q1.vine	Thu Apr 28 08:50:31 2011 -0700
@@ -0,0 +1,7 @@
+From: Dmitriy Morozov <dmitriy@mrzv.org>
+Date: Thu, 28 Apr 2011 08:48:15 -0700
+Subject: changed properties (state=resolved, resolution=fixed)
+Message-Id: <a5d5a0aae0cb2468-f2d6d39b801af175-artemis@vine>
+References: <a5d5a0aae0cb2468-0-artemis@tomas>
+In-Reply-To: <a5d5a0aae0cb2468-0-artemis@tomas>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.issues/a5d5a0aae0cb2468/new/1304005796.M468142P16360Q1.vine	Thu Apr 28 08:50:31 2011 -0700
@@ -0,0 +1,9 @@
+From: Dmitriy Morozov <dmitriy@mrzv.org>
+Date: Thu, 28 Apr 2011 08:49:01 -0700
+Subject: Re: Attachments should be stored without path
+Message-Id: <a5d5a0aae0cb2468-9557f6437dd61990-artemis@vine>
+References: <a5d5a0aae0cb2468-0-artemis@tomas>
+In-Reply-To: <a5d5a0aae0cb2468-0-artemis@tomas>
+
+Now we only store the basename of an attachment. Moreover, when extracting, the
+basename is applied once more (for older attachments that used the full path).
--- a/artemis/artemis.py	Thu Apr 28 08:32:55 2011 -0700
+++ b/artemis/artemis.py	Thu Apr 28 08:50:31 2011 -0700
@@ -255,6 +255,8 @@
                 if not filename:
                     ext = mimetypes.guess_extension(part.get_content_type()) or ''
                     filename = 'attachment-%03d%s' % (counter, ext)
+                else:
+                    filename = os.path.basename(filename)
                 fp = open(filename, 'wb')
                 fp.write(part.get_payload(decode = True))
                 fp.close()
@@ -419,7 +421,7 @@
             # Encode the payload using Base64
             encoders.encode_base64(attachment)
         # Set the filename parameter
-        attachment.add_header('Content-Disposition', 'attachment', filename=filename)
+        attachment.add_header('Content-Disposition', 'attachment', filename=os.path.basename(filename))
         outer.attach(attachment)
     return outer