conflict merge, bugfixes
authoradam <adam@megacz.com>
Fri, 7 May 2004 11:24:28 +0000 (11:24 +0000)
committeradam <adam@megacz.com>
Fri, 7 May 2004 11:24:28 +0000 (11:24 +0000)
darcs-hash:20040507112428-5007d-9dfcfaf3f90bf83feae565e1c74329826dc8b4fa.gz

src/org/ibex/mail/Message.java
src/org/ibex/mail/protocol/SMTP.java
src/org/ibex/mail/store/MessageStore.java
src/org/ibex/mail/target/Script.java

index 00cdf55..96f0873 100644 (file)
@@ -63,7 +63,8 @@ public class Message extends JSReflection {
     }
 
     public static class Address extends JSReflection {
-        public String coerceToString() {
+        public String coerceToString() { return toString(); }
+        public String toString() {
             if (description == null || description.equals("")) return user +"@"+ host;
             return description + " " + "<" + user +"@"+ host + ">";
         }
@@ -128,9 +129,12 @@ public class Message extends JSReflection {
                 headers.put(lastKey, headers.get(lastKey) + s);
                 continue;
             }
-            if (s.indexOf(':') == -1) { /* FIXME */ }
+            if (s.indexOf(':') == -1) {
+                /* FIXME */
+                break;
+            }
 
-            key = s.substring(0, s.indexOf(':'));
+            lastKey = key = s.substring(0, s.indexOf(':'));
             String val = s.substring(0, s.indexOf(':') + 1);
             while(Character.isSpace(val.charAt(0))) val = val.substring(1);
 
@@ -148,9 +152,15 @@ public class Message extends JSReflection {
             
             headers.put(key, val);
         }
+
         allHeaders = all.toString();
+
         StringBuffer body = new StringBuffer();
-        for(String s = rs.readLine(); s != null && !s.equals(""); s = rs.readLine()) body.append(s);
+        for(String s = rs.readLine();; s = rs.readLine()) {
+            if (s == null || (dotTerminatedLikeSMTP && s.equals("."))) break;
+            body.append(s);
+        }
+
         this.body = body.toString();
     }
 
index 4f0b6a2..2b01ed7 100644 (file)
@@ -54,7 +54,7 @@ public class SMTP extends MessageProtocol {
                 int c = read();
                 if (c == -1) throw new EOFException();
                 if (c == '\n') return ret.toString();
-                //if (c == '\r') return ret.toString();
+                if (c == '\r') continue; //return ret.toString();
                 ret.append((char)c);
             }
         }
@@ -121,7 +121,7 @@ public class SMTP extends MessageProtocol {
                         ws.flush();
                         continue;
                     }
-                    command = command.substring(10).trim();
+                    command = command.substring(9).trim();
                     if(command.indexOf(' ') != -1) command = command.substring(0, command.indexOf(' '));
                     Message.Address addr = new Message.Address(command);
                     to.addElement(addr);
index d9a5466..9c452b5 100644 (file)
@@ -65,7 +65,7 @@ public class MessageStore {
     public static class FileBased extends MessageStore {
         private String path;
         private FileBased(String path) throws IOException { new File(this.path = path).mkdirs(); }
-        public FileBased slash(String name) throws IOException { return new FileBased(path + "/" + name); }
+        public MessageStore slash(String name) throws IOException { return new FileBased(path + "/" + name); }
 
         public int[] list() {
             String[] names = new File(path).list();
index c4b7215..4c41be4 100644 (file)
@@ -83,10 +83,10 @@ public class Script extends Target {
                 if (name.equals("log.error")) {    JS.error(a== null ? "**null**" : a.toString()); return null; }
                 switch (nargs) {
                 case 1:
-                    if (name.equals("regexp")) { return new JSRegexp(a, null); }
+                    if (name.equals("regexp")) {return new JSRegexp(a, null); }
                     break;
                 case 2:
-                    if (name.equals("regexp")) { return new JSRegexp(a, b); }
+                    if (name.equals("regexp")) {return new JSRegexp(a, b); }
                 }
             } catch (RuntimeException e) {
                 // FIXME: maybe JSExn should take a second argument, Exception