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

VALIDATOR-368: allowed angle brackets in email addresses #140

Closed
wants to merge 1 commit into from
Closed

VALIDATOR-368: allowed angle brackets in email addresses #140

wants to merge 1 commit into from

Conversation

orionlibs
Copy link

VALIDATOR-368: allowed angle brackets in email addresses

@orionlibs
Copy link
Author

this PR was done 70 days ago. It awaits review and merge

@garydgregory
Copy link
Member

I should be able to come back around to this component is a week or two. I am working on releasing Commons IO ATM...

@nj1830
Copy link

nj1830 commented Oct 26, 2023

Hi, any idea when this fix can be reviewed/merged? thx

Copy link
Contributor

@sebbASF sebbASF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that this changes the behaviour, I think it needs to be optional.

One way to do that would be to provide a lenient matcher that strips off the comment and angle brackets and then calls the existing validator with the embedded email address.
Rather than add yet another ctor parameter, it might make sense as a subclass.

private static final String IP_DOMAIN_REGEX = "^\\[(.*)\\]$";
private static final String USER_REGEX = "^" + WORD + "(\\." + WORD + ")*$";
private static final String FULL_NAME_EMAIL_REGEX = "^(.+)<" + EMAIL_CHARACTERS + ">$";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why capture the leading comment?
It is not needed.

@@ -407,6 +407,8 @@ public void testEmailUserName() {
assertFalse(validator.isValid("Abc@def@example.com"));

assertTrue(validator.isValid("space\\ monkey@example.com"));

assertTrue(validator.isValid("Abigail Jones <abigail@example.com>"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need some tests to show that user part and domain part are properly validated

@@ -179,15 +182,28 @@ public boolean isValid(final String email) {

// Check the whole email address structure
final Matcher emailMatcher = EMAIL_PATTERN.matcher(email);
if (!emailMatcher.matches()) {
final Matcher fullnameEmailMatcher = EMAIL_WITH_FULL_NAME_PATTERN.matcher(email);
final boolean fullnameEmailMatches = fullnameEmailMatcher.matches();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure you need to keep this variable

@orionlibs
Copy link
Author

this PR has been open for half a year

@sebbASF
Copy link
Contributor

sebbASF commented Dec 3, 2023

There are some review comments that need to be addressed before it can be considered for inclusion in the code base.

@orionlibs orionlibs closed this Dec 3, 2023
@Lonzak
Copy link

Lonzak commented Dec 4, 2023

We should really find a solution for this - constructor parameter || lenient matcher I don't mind. Any solution helps

@orionlibs orionlibs deleted the VALIDATOR-368-allow-angle-brackets-in-email-address branch December 4, 2023 08:33
@sebbASF
Copy link
Contributor

sebbASF commented Dec 4, 2023

Contributions are still welcome.
However the new behaviour needs to be optional, and there need to be some tests.

It does not look to be particularly difficult, but someone has to do the work...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants