From: Gregor Hoffleit <gregor@hoffleit.de>
To: sup-talk <sup-talk@rubyforge.org>
Subject: [sup-talk] [PATCH] Attachment filenames: RFC2184 and extension guessing
Date: Wed, 07 Oct 2009 12:52:34 +0200 [thread overview]
Message-ID: <1254912361-sup-5340@sam.mediasupervision.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 673 bytes --]
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";
Bugs:
1. Sup fails to detect these filenames.
2. 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.
Regards,
Gregor Hoffleit
[-- 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: 140 bytes --]
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk
reply other threads:[~2009-10-07 10:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1254912361-sup-5340@sam.mediasupervision.de \
--to=gregor@hoffleit.de \
--cc=sup-talk@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