- String s = s0.trim();
- if (s.indexOf('<') == -1) description = "";
- else {
- if (s.indexOf('>') == -1) { throw new Malformed("found open-angle-bracket (<) but not close-angle-bracket (>)"); }
- description = s.substring(0, s.indexOf('<')) + s.substring(s.indexOf('>') + 1);
- s = s.substring(s.indexOf('<') + 1, s.indexOf('>'));
+ boolean good = false;
+ try {
+ String s = s0.trim();
+ if (s.indexOf('<') == -1) {
+ if (s.indexOf(' ') == -1) {
+ description = "";
+ } else {
+ description = s.substring(s.indexOf(' ')).trim();
+ s = s.substring(0, s.indexOf(' '));
+ }
+ } else {
+ if (s.indexOf('>') == -1) { throw new Malformed("found open-angle-bracket (<) but not close-angle-bracket (>)"); }
+ description = s.substring(0, s.indexOf('<')) + s.substring(s.indexOf('>') + 1);
+ s = s.substring(s.indexOf('<') + 1, s.indexOf('>'));
+ }
+ if (s.trim().length() == 0) {
+ user = null;
+ host = null;
+ good = true;
+ } else if (s.indexOf('@') == -1) { throw new Malformed("no @-sign in email address \""+s0+"\"");
+ } else {
+ user = s.substring(0, s.indexOf('@'));
+ host = s.substring(s.indexOf('@')+1);
+ good = true;
+ }
+ } finally {
+ if (!good) Log.error(Address.class, "problem parsing: \""+s0+"\"");