]> git.cworth.org Git - sup/commitdiff
be better about picking extensions for attachments
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Mon, 10 Dec 2007 03:55:53 +0000 (03:55 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Mon, 10 Dec 2007 03:55:53 +0000 (03:55 +0000)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@760 5c8cc53c-5e98-4d25-b20a-d8db53a31250

lib/sup/message.rb

index 69625fcabc370ea316e9a6dc4b6f9c15cea61ca7..fbea1f66a960cde892516d8eb3912dcd5fcc3d3d 100644 (file)
@@ -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.