lib/sup/mbox.rb in sup-0.6 vs lib/sup/mbox.rb in sup-0.7
- old
+ new
@@ -9,20 +9,25 @@
## and should be moved somewhere else.
##
## TODO: move functionality to somewhere better, like message.rb
module MBox
BREAK_RE = /^From \S+/
- HEADER_RE = /\s*(.*?\S)\s*/
+ HEADER_RE = /\s*(.*?)\s*/
def read_header f
header = {}
last = nil
## i do it in this weird way because i am trying to speed things up
## when scanning over large mbox files.
while(line = f.gets)
case line
+ ## these three can occur multiple times, and we want the first one
+ when /^(Delivered-To):#{HEADER_RE}$/i,
+ /^(X-Original-To):#{HEADER_RE}$/i,
+ /^(Envelope-To):#{HEADER_RE}$/i: header[last = $1] ||= $2
+
when /^(From):#{HEADER_RE}$/i,
/^(To):#{HEADER_RE}$/i,
/^(Cc):#{HEADER_RE}$/i,
/^(Bcc):#{HEADER_RE}$/i,
/^(Subject):#{HEADER_RE}$/i,
@@ -31,17 +36,12 @@
/^(In-Reply-To):#{HEADER_RE}$/i,
/^(Reply-To):#{HEADER_RE}$/i,
/^(List-Post):#{HEADER_RE}$/i,
/^(List-Subscribe):#{HEADER_RE}$/i,
/^(List-Unsubscribe):#{HEADER_RE}$/i,
- /^(Status):#{HEADER_RE}$/i: header[last = $1] = $2
+ /^(Status):#{HEADER_RE}$/i,
+ /^(X-\S+):#{HEADER_RE}$/: header[last = $1] = $2
when /^(Message-Id):#{HEADER_RE}$/i: header[mid_field = last = $1] = $2
-
- ## these next three can occur multiple times, and we want the
- ## first one
- when /^(Delivered-To):#{HEADER_RE}$/i,
- /^(X-Original-To):#{HEADER_RE}$/i,
- /^(Envelope-To):#{HEADER_RE}$/i: header[last = $1] ||= $2
when /^\r*$/: break
when /^\S+:/: last = nil # some other header we don't care about
else
header[last] += " " + line.chomp.gsub(/^\s+/, "") if last