Archive of RubyForge sup-devel mailing list
 help / color / mirror / Atom feed
From: Gregor Hoffleit <sup-bugs@masanjin.net>
To: sup-devel@rubyforge.org
Subject: [sup-devel] [issue63] Attachment filenames: RFC2184 and extension guessing
Date: Thu, 04 Feb 2010 17:03:41 +0000	[thread overview]
Message-ID: <1265303021.03.0.840779379479.issue63@masanjin.net> (raw)
In-Reply-To: <1265303021.03.0.840779379479.issue63@masanjin.net>

[-- Attachment #1: Type: text/plain, Size: 1075 bytes --]


New submission from Gregor Hoffleit <gregor@hoffleit.de>:

I noticed sup has trouble handling attachments sent by Roundcube webmail. 
Somehow, those mails use an alternative encoding of filenames, specified in 
RFC2184:

    Content-Transfer-Encoding: base64
    Content-Type: image/jpeg;
     name*="UTF-8''20090912-i004232-gr000.jpg";
    Content-Disposition: attachment;
     filename*="UTF-8''20090912-i004232-gr000.jpg";

Sup fails to detect these filenames.

When trying to save these attachements, the filenames generated by sup have a 
trailing semicolon.

The attached patch is a quick and dirty fix for these specific problems.
There's probably a better way to implement this.

----------
files: rfc2184.diff
messages: 150
nosy: flight
priority: bug
ruby_version: 1.8.5
status: unread
sup_version: 0.10.2
title: Attachment filenames: RFC2184 and extension guessing

_________________________________________
Sup issue tracker <sup-bugs@masanjin.net>
<http://masanjin.net/sup-bugs/issue63>
_________________________________________

[-- Attachment #2: rfc2184.diff --]
[-- Type: application/octet-stream, Size: 954 bytes --]

diff --git a/lib/sup/message.rb b/lib/sup/message.rb
index f9f87de..4ad0b88 100644
--- a/lib/sup/message.rb
+++ b/lib/sup/message.rb
@@ -477,6 +477,10 @@ private
           $1
         elsif m.header["Content-Type"] && m.header["Content-Type"] =~ /name="?(.*?[^\\])("|;|$)/i
           $1
+        elsif m.header["Content-Disposition"] && m.header["Content-Disposition"] =~ /filename\*="?UTF-8''(.*?[^\\])("|;|$)/
+          $1
+        elsif m.header["Content-Type"] && m.header["Content-Type"] =~ /name\*="?UTF-8''(.*?[^\\])("|;|$)/i
+          $1
 
         ## haven't found one, but it's a non-text message. fake
         ## it.
@@ -486,7 +490,7 @@ private
           extension =
             case m.header["Content-Type"]
             when /text\/html/ then "html"
-            when /image\/(.*)/ then $1
+            when /image\/([^;]*)/ then $1
             end
 
           ["sup-attachment-#{Time.now.to_i}-#{rand 10000}", extension].join(".")

[-- Attachment #3: Type: text/plain, Size: 143 bytes --]

_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel

           reply	other threads:[~2010-02-04 17:14 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <1265303021.03.0.840779379479.issue63@masanjin.net>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1265303021.03.0.840779379479.issue63@masanjin.net \
    --to=sup-bugs@masanjin.net \
    --cc=sup-devel@rubyforge.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox