From 7ff103d50a6fb5b3d1e3f9e05ebf1d8f3e080043 Mon Sep 17 00:00:00 2001 From: William Morgan Date: Wed, 26 Mar 2008 09:38:34 -0700 Subject: [PATCH] handle carriage returns in mbox files --- lib/sup/mbox.rb | 5 +++-- lib/sup/mbox/loader.rb | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/sup/mbox.rb b/lib/sup/mbox.rb index 0ce52fe..2494897 100644 --- a/lib/sup/mbox.rb +++ b/lib/sup/mbox.rb @@ -41,8 +41,8 @@ module MBox /^(X-Original-To):\s+(.*)$/i, /^(Envelope-To):\s+(.*)$/i: header[last = $1] ||= $2 - when /^$/: break - when /^\S+: /: last = nil # some other header we don't care about + when /^\r*$/: break + when /^\S+:/: last = nil # some other header we don't care about else header[last] += " " + line.chomp.gsub(/^\s+/, "") if last end @@ -65,6 +65,7 @@ module MBox header end + ## never actually called def read_body f body = [] f.each_line do |l| diff --git a/lib/sup/mbox/loader.rb b/lib/sup/mbox/loader.rb index 58f4fc7..7fe9129 100644 --- a/lib/sup/mbox/loader.rb +++ b/lib/sup/mbox/loader.rb @@ -85,7 +85,7 @@ class Loader < Source ret = "" @mutex.synchronize do @f.seek offset - until @f.eof? || (l = @f.gets) =~ /^$/ + until @f.eof? || (l = @f.gets) =~ /^\r*$/ ret += l end end -- 2.43.0