# HG changeset patch # User Dmitriy Morozov # Date 1304005831 25200 # Node ID 88c088722a30963109172f487c77810a268bf027 # Parent 50ecb341130d95b728532e565a935c9279282dfb Fixed #a5d (use basename() on attachment filenames) diff -r 50ecb341130d -r 88c088722a30 .issues/a5d5a0aae0cb2468/new/1276151607.M152689P10154Q1.tomas --- 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 " Date: Thu, 10 Jun 2010 08:31:23 +0200 -State: new +State: resolved Subject: Attachments should be stored without path Message-Id: +resolution: fixed Attachments are stored with their path causing attachment extract operation to override the original file. diff -r 50ecb341130d -r 88c088722a30 .issues/a5d5a0aae0cb2468/new/1304004853.M131867P15337Q1.vine --- /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 +Date: Thu, 28 Apr 2011 08:34:13 -0700 +Subject: changed properties (state=in-progress) +Message-Id: +References: +In-Reply-To: + diff -r 50ecb341130d -r 88c088722a30 .issues/a5d5a0aae0cb2468/new/1304005695.M962593P16333Q1.vine --- /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 +Date: Thu, 28 Apr 2011 08:48:15 -0700 +Subject: changed properties (state=resolved, resolution=fixed) +Message-Id: +References: +In-Reply-To: + diff -r 50ecb341130d -r 88c088722a30 .issues/a5d5a0aae0cb2468/new/1304005796.M468142P16360Q1.vine --- /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 +Date: Thu, 28 Apr 2011 08:49:01 -0700 +Subject: Re: Attachments should be stored without path +Message-Id: +References: +In-Reply-To: + +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). diff -r 50ecb341130d -r 88c088722a30 artemis/artemis.py --- 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