* [sup-talk] [PATCH] expand file paths and rescue enoent exceptions when adding attachments
[not found] <21aa9f0801261918j2890aee2yeb52484a95b786c3@mail.gmail.com>
@ 2008-01-27 3:35 ` brabuhr
2008-02-03 2:20 ` William Morgan
0 siblings, 1 reply; 2+ messages in thread
From: brabuhr @ 2008-01-27 3:35 UTC (permalink / raw)
On 1/26/08, Daniel Wagner <daniel at wagner-home.com> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/sup-talk/attachments/20080126/533da985/attachment.html
^ permalink raw reply [flat|nested] 2+ messages in thread
* [sup-talk] [PATCH] expand file paths and rescue enoent exceptions when adding attachments
2008-01-27 3:35 ` [sup-talk] [PATCH] expand file paths and rescue enoent exceptions when adding attachments brabuhr
@ 2008-02-03 2:20 ` William Morgan
0 siblings, 0 replies; 2+ messages in thread
From: William Morgan @ 2008-02-03 2:20 UTC (permalink / raw)
I had already come up with a patch for this. Sorry! git diff
master..019854 if you're curious.
--
William <wmorgan-sup at masanjin.net>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-02-03 2:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <21aa9f0801261918j2890aee2yeb52484a95b786c3@mail.gmail.com>
2008-01-27 3:35 ` [sup-talk] [PATCH] expand file paths and rescue enoent exceptions when adding attachments brabuhr
2008-02-03 2:20 ` William Morgan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox