* [sup-devel] [issue63] Attachment filenames: RFC2184 and extension guessing
@ 2010-02-04 17:03 Gregor Hoffleit
0 siblings, 0 replies; only message in thread
From: Gregor Hoffleit @ 2010-02-04 17:03 UTC (permalink / raw)
To: sup-devel
[-- 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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-02-04 17:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-04 17:03 [sup-devel] [issue63] Attachment filenames: RFC2184 and extension guessing Gregor Hoffleit
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox