Skip to content

CCD-6096: Disallow invalid characters in Email addresses #2528

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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

JamesCollettCGI
Copy link
Contributor

JIRA link

https://tools.hmcts.net/jira/browse/CCD-6096

Change description

Disallow less than and greater than symbols in Email addresses.
Also fixed minor typos in unit tests (result01 to result03 and result01 to result02).

Does this PR introduce a breaking change?

[ ] Yes
[x] No

@JamesCollettCGI
Copy link
Contributor Author

Copy link
Contributor

@aktaskaan aktaskaan left a comment

Choose a reason for hiding this comment

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

Based on what I see in the implementation, the InternetAddress.validate() method provides relatively weak standard email validation or does not fully meet our requirements. If we are not using any additional regex-based validation, we will need to make similar adjustments for the other validations (<>", "()", and "[email protected], "user@email" AND name[email protected] ) mentioned in the main ticket (DFR-3419).

Instead of doing this, we could use the more robust Apache email validation. The project is already defined in data-store with version 1.6.0, which is from 2017. Updating it to the latest 1.9.0 version would allow us to use the following method, which performs significantly better validation:

org.apache.commons.validator.routines.EmailValidator.getInstance().isValid(email);

I ran some comparative tests, and Apache's validator performs much better. While this might introduce some additional testing effort, I believe it’s worth reviewing. We could also get @RebeccaBaker 's opinion on this.

…idatorTest to test for invalid comma or space.
@JamesCollettCGI JamesCollettCGI changed the title CCD-6096: Disallow less than and greater than symbols in Email addresses CCD-6096: Disallow invalid characters in Email addresses Feb 12, 2025
@JamesCollettCGI
Copy link
Contributor Author

Updated EmailValidator to invalidate comma or space. Updated EmailValidatorTest to test for invalid comma or space.

Copy link
Contributor

@aktaskaan aktaskaan left a comment

Choose a reason for hiding this comment

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

Apache common validator will be updated to 1.9.0 version with Spring boot 3 upgrade..
Also, since this change will introduce more constraint validation, it may be put in demo by QA for a while.

JamesCollettCGI added 4 commits March 5, 2025 11:07
…-email-address' of github.com:hmcts/ccd-data-store-api into CCD-6096-disallow-less-than-and-greater-than-symbols-in-email-address
@hmcts-jenkins-a-to-c hmcts-jenkins-a-to-c bot requested a deployment to preview March 21, 2025 11:24 Abandoned
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants