Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing the case sensitivity with toUpperCase() #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,15 @@ public String toString() {

protected static MailAddress parsePath(int maxNumParams, String prefix, String str) throws SmtpCommandException {

str = str.toUpperCase();
String[] params = parseParameters(1, maxNumParams, str);

if (!(StringUtils.startsWith(params[0], prefix) || !StringUtils.endsWith(params[0], ToolMailAddressUtils.MAIL_ADDR_PART_PERSONAL_ADDR_SUFFIX))) {
if (!(StringUtils.startsWith(params[0].toUpperCase(), prefix) || !StringUtils.endsWith(params[0].toUpperCase(), ToolMailAddressUtils.MAIL_ADDR_PART_PERSONAL_ADDR_SUFFIX))) {
throw new SmtpCommandException(new SmtpReplyImpl(SmtpReplyCode.SYNTAX_ERROR_ARGUMENTS, String.format("Required syntax: '%slocal@domain%s'", prefix,
ToolMailAddressUtils.MAIL_ADDR_PART_PERSONAL_ADDR_SUFFIX)));
}

int pathLen =
(params[0] = StringUtils.removeEnd(StringUtils.removeStart(params[0], prefix), ToolMailAddressUtils.MAIL_ADDR_PART_PERSONAL_ADDR_SUFFIX)).length();
(params[0] = StringUtils.removeEnd(StringUtils.removeStart(params[0].toUpperCase(), prefix), ToolMailAddressUtils.MAIL_ADDR_PART_PERSONAL_ADDR_SUFFIX)).length();

if (pathLen > MAX_PATH_LEN) {
throw new SmtpCommandException(new SmtpReplyImpl(SmtpReplyCode.SYNTAX_ERROR_ARGUMENTS, String.format("Path too long: %d > %d", pathLen,
Expand All @@ -72,7 +71,7 @@ protected static MailAddress parsePath(int maxNumParams, String prefix, String s
if (!pathMatcher.matches()) {
throw new SmtpCommandException(new SmtpReplyImpl(SmtpReplyCode.SYNTAX_ERROR_ARGUMENTS, String.format("Malformed email address: %s", params[0])));
}
return new MailAddressImpl(pathMatcher.group(1).toLowerCase());
return new MailAddressImpl(pathMatcher.group(1));
}

protected static String[] parseParameters(int numParams, String str) throws SmtpCommandException {
Expand Down Expand Up @@ -106,4 +105,4 @@ protected static String[] parseParameters(Function<String, String[]> splitter, i
protected ToolStrBuilder parametersToString(ToolStrBuilder builder) {
return builder;
}
}
}