commit 4101d2af352441d698477398f4fe76ece3906c8b
parent 95f44f6753f03acf72d0e23e6673d62703692719
Author: wmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Date: Mon, 10 Dec 2007 03:55:53 +0000
be better about picking extensions for attachments
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@760 5c8cc53c-5e98-4d25-b20a-d8db53a31250
Diffstat:
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/lib/sup/message.rb b/lib/sup/message.rb
@@ -359,8 +359,16 @@ private
## haven't found one, but it's a non-text message. fake
## it.
+ ##
+ ## TODO: make this less lame.
elsif m.header["Content-Type"] && m.header["Content-Type"] !~ /^text\/plain/
- "sup-attachment-#{Time.now.to_i}-#{rand 10000}"
+ extension =
+ case m.header["Content-Type"]
+ when /text\/html/: "html"
+ when /image\/(.*)/: $1
+ end
+
+ ["sup-attachment-#{Time.now.to_i}-#{rand 10000}", extension].join(".")
end
## if there's a filename, we'll treat it as an attachment.