commit 93fadea6e543204f68ae6ea511837ebcae512f51
parent b57bc5299cc99dd7182b0b27329ace13affca779
Author: wmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Date: Sun, 28 Oct 2007 03:36:32 +0000
make >From thing work correctly
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@638 5c8cc53c-5e98-4d25-b20a-d8db53a31250
Diffstat:
4 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/doc/TODO b/doc/TODO
@@ -4,8 +4,8 @@ for 0.2
x bugfix: contacts.txt isn't parsed correctly when there are spaces in
aliases
x bugfix: @ signs in names make sendmail die silently
-_ bugfix: sent.mbox and >From
-_ bugfix: tokenized email addresses (amazon.com, etc)
+x bugfix: sent.mbox and >From
+x bugfix: tokenized email addresses (amazon.com, etc)
x bugfix: trailing spaces in buffermanager.ask
x bugfix: need to URL-unescape maildir folders
x bugfix: downcasing tab completion
diff --git a/lib/sup/mbox/loader.rb b/lib/sup/mbox/loader.rb
@@ -68,7 +68,11 @@ class Loader < Source
@f.seek offset
begin
RMail::Mailbox::MBoxReader.new(@f).each_message do |input|
- return RMail::Parser.read(input)
+ m = RMail::Parser.read(input)
+ if m.body
+ m.body.gsub!(/^>From /, "From ")
+ end
+ return m
end
rescue RMail::Parser::Error => e
raise FatalSourceError, "error parsing mbox file: #{e.message}"
diff --git a/lib/sup/modes/edit-message-mode.rb b/lib/sup/modes/edit-message-mode.rb
@@ -218,9 +218,9 @@ protected
BufferManager.flash "Sending..."
begin
- IO.popen(acct.sendmail, "w") { |p| write_full_message_to p, date }
+ IO.popen(acct.sendmail, "w") { |p| write_full_message_to p, date, false }
raise SendmailCommandFailed, "Couldn't execute #{acct.sendmail}" unless $? == 0
- SentManager.write_sent_message(date, from_email) { |f| write_full_message_to f, date }
+ SentManager.write_sent_message(date, from_email) { |f| write_full_message_to f, date, true }
BufferManager.kill_buffer buffer
BufferManager.flash "Message sent!"
true
@@ -237,7 +237,7 @@ protected
BufferManager.flash "Saved for later editing."
end
- def write_full_message_to f, date=Time.now
+ def write_full_message_to f, date=Time.now, escape=false
m = RMail::Message.new
@header.each do |k, v|
next if v.nil? || v.empty?
@@ -257,10 +257,12 @@ protected
if @attachments.empty?
m.header["Content-Type"] = "text/plain; charset=#{$encoding}"
m.body = @body.join
+ m.body = sanitize_body m.body if escape
m.body += sig_lines.join("\n") unless $config[:edit_signature]
else
body_m = RMail::Message.new
body_m.body = @body.join
+ body_m.body = sanitize_body body_m.body if escape
body_m.body += sig_lines.join("\n") unless $config[:edit_signature]
body_m.header["Content-Type"] = "text/plain; charset=#{$encoding}"
body_m.header["Content-Disposition"] = "inline"
@@ -271,6 +273,8 @@ protected
f.puts m.to_s
end
+ ## TODO: remove this. redundant with write_full_message_to.
+ ##
## this is going to change soon: draft messages (currently written
## with full=false) will be output as yaml.
def write_message f, full=true, date=Time.now
@@ -290,12 +294,16 @@ EOS
end
f.puts
- f.puts @body.map { |l| l =~ /^From / ? ">#{l}" : l }
+ f.puts sanitize_body(@body.join)
f.puts sig_lines if full unless $config[:edit_signature]
end
private
+ def sanitize_body body
+ body.gsub(/^From /, ">From ")
+ end
+
def mentions_attachments?
@body.any? { |l| l =~ /^[^>]/ && l =~ /\battach(ment|ed|ing|)\b/i }
end
diff --git a/lib/sup/sent.rb b/lib/sup/sent.rb
@@ -21,6 +21,7 @@ class SentManager
f.puts "From #{from_email} #{date}"
yield f
end
+
@source.each do |offset, labels|
m = Message.new :source => @source, :source_info => offset, :labels => @source.labels
Index.sync_message m