On Thu, 2003-07-17 at 14:07, Chuck Simpson wrote:
> My hostname has an underscore character '_' in it and when I run the
> first test to check sendmail relaying to James I get the following in
> the smtpserver log:
>
> Error parsing sender address: \
> [EMAIL PROTECTED]: Invalid character at 13
>
> I rechecked RFC822 and it does not proscribe underscores in hostnames.
> Why does James not handle this?
>
I don't usually answer my own posts, but this may help someone else. I
had a few minutes so I checked the James sources and found the problem
in the org.apache.mailet.MailAddress class. The parseDomainName class
should be changed as follows:
private String parseDomainName(String address) throws ParseException {
StringBuffer resultSB = new StringBuffer();
//<name> ::= <a> <ldh-str> <let-dig>
//<ldh-str> ::= <let-dig-hyp> | <let-dig-hyp> <ldh-str>
//<let-dig> ::= <a> | <d>
//<let-dig-hyp> ::= <a> | <d> | "-"
//<a> ::= any one of the 52 alphabetic characters A through Z
// in upper case and a through z in lower case or "_"
^^^^^^
// add underscore to legal alphabetics
//<d> ::= any one of the ten digits 0 through 9
// basically, this is a series of letters, digits, and hyphens,
// but it can't start with a digit or hypthen
// and can't end with a hyphen
// in practice though, we should relax this as domain names can
start
// with digits as well as letters. So only check that doesn't
start
// or end with hyphen.
while (true) {
if (pos >= address.length()) {
break;
}
char ch = address.charAt(pos);
if ((ch >= '0' && ch <= '9') ||
(ch >= 'a' && ch <= 'z') ||
(ch >= 'A' && ch <= 'Z') ||
(ch == '-') || (ch == '_')) {
// add the underscore character ^^^^^^^^^^
resultSB.append(ch);
pos++;
continue;
}
if (ch == '.') {
break;
}
throw new ParseException("Invalid character at " + pos);
}
String result = resultSB.toString();
if (result.startsWith("-") || result.endsWith("-")) {
throw new ParseException("Domain name cannot begin or end
with a hyphen \"-\" at position " + (pos + 1));
}
return result;
}
Chuck
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]