From 9f0c3edcacb11544739b338c52afbc6efaaee5c0 Mon Sep 17 00:00:00 2001 From: adam Date: Fri, 7 May 2004 11:24:28 +0000 Subject: [PATCH] conflict merge, bugfixes darcs-hash:20040507112428-5007d-9dfcfaf3f90bf83feae565e1c74329826dc8b4fa.gz --- src/org/ibex/mail/Message.java | 18 ++++++++++++++---- src/org/ibex/mail/protocol/SMTP.java | 4 ++-- src/org/ibex/mail/store/MessageStore.java | 2 +- src/org/ibex/mail/target/Script.java | 4 ++-- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/org/ibex/mail/Message.java b/src/org/ibex/mail/Message.java index 00cdf55..96f0873 100644 --- a/src/org/ibex/mail/Message.java +++ b/src/org/ibex/mail/Message.java @@ -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(); } diff --git a/src/org/ibex/mail/protocol/SMTP.java b/src/org/ibex/mail/protocol/SMTP.java index 4f0b6a2..2b01ed7 100644 --- a/src/org/ibex/mail/protocol/SMTP.java +++ b/src/org/ibex/mail/protocol/SMTP.java @@ -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); diff --git a/src/org/ibex/mail/store/MessageStore.java b/src/org/ibex/mail/store/MessageStore.java index d9a5466..9c452b5 100644 --- a/src/org/ibex/mail/store/MessageStore.java +++ b/src/org/ibex/mail/store/MessageStore.java @@ -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(); diff --git a/src/org/ibex/mail/target/Script.java b/src/org/ibex/mail/target/Script.java index c4b7215..4c41be4 100644 --- a/src/org/ibex/mail/target/Script.java +++ b/src/org/ibex/mail/target/Script.java @@ -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 -- 1.7.10.4