]> git.cworth.org Git - sup/blobdiff - lib/sup/mbox.rb
Merge commit 'origin/various-mbox-fixes'
[sup] / lib / sup / mbox.rb
index 5dd89b707d4709678d346a9f4490e2a3a672f101..0d941b1d8ae341b86bcf6303e752c3c4bb1c36e5 100644 (file)
@@ -6,6 +6,20 @@ require "sup/rfc2047"
 module Redwood
 
 module MBox
-  BREAK_RE = /^From \S+/ ######### TODO REMOVE ME
+  BREAK_RE = /^From \S+ (.+)$/
+
+  def is_break_line? l
+    l =~ BREAK_RE or return false
+    time = $1
+    begin
+      ## hack -- make Time.parse fail when trying to substitute values from Time.now
+      Time.parse time, 0
+      true
+    rescue NoMethodError
+      Redwood::log "found invalid date in potential mbox split line, not splitting: #{l.inspect}"
+      false
+    end
+  end
+  module_function :is_break_line?
 end
 end