deal with null Envelope
authoradam <adam@megacz.com>
Thu, 5 Aug 2004 23:23:40 +0000 (23:23 +0000)
committeradam <adam@megacz.com>
Thu, 5 Aug 2004 23:23:40 +0000 (23:23 +0000)
darcs-hash:20040805232340-5007d-8f623934c79b5bfaa3b182e27d890f8e10f59bc6.gz

src/org/ibex/mail/Message.java

index c26b58e..d1434ad 100644 (file)
@@ -37,10 +37,10 @@ public class Message extends MIME.Part {
         public final Address to;
         public final Address from;
         public static Envelope augment(Envelope e, MIME.Headers h) {
-            if (e.from != null && e.to != null) return e;
-            Address to   = e.to   == null ? Address.parse(h.gets("X-org.ibex.mail.headers.envelope.To"))   : e.to;
-            Address from = e.from == null ? Address.parse(h.gets("X-org.ibex.mail.headers.envelope.From")) : e.from;
-            return new Envelope(from, to, e.arrival);
+            if (e != null && e.from != null && e.to != null) return e;
+            Address to   = (e==null||e.to==null)   ? Address.parse(h.gets("X-org.ibex.mail.headers.envelope.To"))   : e.to;
+            Address from = (e==null||e.from==null) ? Address.parse(h.gets("X-org.ibex.mail.headers.envelope.From")) : e.from;
+            return new Envelope(from, to, e==null ? new Date() : e.arrival);
         }
     }
 
@@ -61,9 +61,9 @@ public class Message extends MIME.Part {
         super(stream, null, false);
         Vec resent = new Vec(), traces = new Vec();
         this.envelope     = Envelope.augment(envelope, headers);
-        this.to           = headers.gets("To") == null       ? envelope.to    : Address.parse(headers.gets("To"));
-        this.from         = headers.gets("From") == null     ? envelope.from  : Address.parse(headers.gets("From"));
-        this.replyto      = headers.gets("Reply-To") == null ? null           : Address.parse(headers.gets("Reply-To"));
+        this.to           = headers.gets("To") == null       ? this.envelope.to    : Address.parse(headers.gets("To"));
+        this.from         = headers.gets("From") == null     ? this.envelope.from  : Address.parse(headers.gets("From"));
+        this.replyto      = headers.gets("Reply-To") == null ? null                : Address.parse(headers.gets("Reply-To"));
         this.subject      = headers.gets("Subject");
         this.messageid    = headers.gets("Message-Id");
         this.cc           = Address.list(headers.gets("Cc"));