On 1/26/08, Daniel Wagner <[EMAIL PROTECTED]> wrote:
> If I type in a filename that starts with ~ at the attachment prompt, sup
> crashes.

---
 lib/sup/modes/edit-message-mode.rb |    4 ++++
 lib/sup/util.rb                    |    3 ++-
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/lib/sup/modes/edit-message-mode.rb
b/lib/sup/modes/edit-message-mode.rb
index 6a7f273..9412235 100644
--- a/lib/sup/modes/edit-message-mode.rb
+++ b/lib/sup/modes/edit-message-mode.rb
@@ -151,6 +151,10 @@ EOS
    @attachments << RMail::Message.make_file_attachment(fn)
    @attachment_names << fn
    update
+  rescue Errno::ENOENT => e
+    Redwood::log "Cannot add attachment: #{e.message}"
+    Redwood::log e.backtrace.join("\n")
+    Redwood::BufferManager.flash "Could not add attachment: #{e.message}"
  end

  def delete_attachment
diff --git a/lib/sup/util.rb b/lib/sup/util.rb
index ceaf0b8..51339d6 100644
--- a/lib/sup/util.rb
+++ b/lib/sup/util.rb
@@ -57,8 +57,9 @@ module RMail
  class Message
    def self.make_file_attachment fn
      bfn = File.basename fn
+      fp = File.expand_path fn
      t = MIME::Types.type_for(bfn).first || MIME::Types.type_for
("exe").first
-      make_attachment IO.read(fn), t.content_type, t.encoding, bfn.to_s
+      make_attachment IO.read(fp), t.content_type, t.encoding, bfn.to_s
    end

    def charset
--
1.5.2.5
_______________________________________________
sup-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/sup-talk

Reply via email to