You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The validate method tightly couples validation for injection attacks alongside email addresses validation. These are different types of validation. Consider:
public boolean validate(final Email email) {
validateSenders(email);
validateRecipients(email);
validateAttacks(email);
}
This would allow for global settings to control validation. For example:
public boolean validate(final Email email) {
if( validate() ) {
validateSenders(email);
validateRecipients(email);
validateAttacks(email);
}
}
public boolean validateSenders(final Email email) {
if( validateSenders() ) {
final InternetAddress[] addresses = email.getAddresses(FROM);
if (!EmailAddressValidator.isValid(addresses, getEmailAddressCriteria())) {
// ...
}
}
This tells Simple Java Mail that there is no email address criteria to check and so will omit email address validation completely, yet keep the injection tests.
Your analyses is spot on. Moreover emailAddressCriteria is garuanteed to be non-null, so the null-check is not only wrong, it is completely superfluous.
Activity
bbottema commentedon Sep 20, 2018
What's the use case for global control settings? Why not always check everything?
bbottema commentedon Sep 22, 2018
This is already possible:
This tells Simple Java Mail that there is no email address criteria to check and so will omit email address validation completely, yet keep the injection tests.
Does this solve your problem?
bbottema commentedon Sep 26, 2018
@davejarvis, had any luck with this yet?
[-]Separate validation concerns[/-][+]Email addresses validated despite cleared validation validation criteria[/+]#167: fixed testing if there are email validation criteria
bbottema commentedon Oct 3, 2018
Your analyses is spot on. Moreover
emailAddressCriteriais garuanteed to be non-null, so the null-check is not only wrong, it is completely superfluous.Released fix in 5.0.6, please confirm.
[-]Email addresses validated despite cleared validation validation criteria[/-][+]Email addresses validated despite cleared validation criteria[/+]