in geronimo-mail_2.1_spec/src/main/java/jakarta/mail/internet/AddressParser.java [1032:1085]
private void validateGroupMailbox(final TokenStream tokens) throws AddressException {
final AddressToken first = tokens.nextRealToken();
// is this just a null address in the list? then push the terminator back and return.
if (first.type == COMMA || first.type == SEMICOLON) {
tokens.pushToken(first);
return;
}
// now we need to scan ahead to see if we can determine the type.
AddressToken token = first;
// we need to scan forward to figure out what sort of address this is.
while (first != null) {
switch (token.type) {
// until we know the context, these are all just ignored.
case QUOTED_LITERAL:
case ATOM:
break;
// a LEFT_ANGLE indicates we have a full RFC822 mailbox form. The leading phrase
// is the personal info. The address is inside the brackets.
case LEFT_ANGLE:
tokens.pushToken(first);
validatePhrase(tokens, false);
validateRouteAddr(tokens, true);
return;
// we've hit a period as the first non-word token. This should be part of a local-part
// of an address.
case PERIOD:
// we've hit an "@" as the first non-word token. This is probably a simple address in
// the form "user@domain".
case AT_SIGN:
tokens.pushToken(first);
validateAddressSpec(tokens);
return;
// reached the end of string...this might be a null address, or one of the very simple name
// forms used for non-strict RFC822 versions. Reset, and try that form
case COMMA:
// this is the end of the group...handle it like a comma for now.
case SEMICOLON:
tokens.pushToken(first);
validateAddressSpec(tokens);
return;
case END_OF_TOKENS:
illegalAddress("Missing ';'", token);
}
token = tokens.nextRealToken();
}
}