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

Fixed email pattern to allow emails TLDs with more than 4 characters #2958

Open
wants to merge 4 commits into
base: dspace-7_x
Choose a base branch
from

Conversation

oscar-escire
Copy link
Contributor

Hi @tdonohue, I'm @jtimal partner. We have been working on this issue and we will send you the PR.

References

Description

I changed the email validation pattern on 4 components. This validation pattern is a version of HTML5 pattern that request user to use a email "[email protected]" style and to add at least one LTD.

Instructions for Reviewers

  • Start a new ePerson register
  • Introduce a valid email

List of changes in this PR:

  • Changed email validation pattern

Checklist

  • My PR is small in size (e.g. less than 1,000 lines of code, not including comments & specs/tests), or I have provided reasons as to why that's not possible.
  • My PR passes ESLint validation using yarn lint
  • My PR doesn't introduce circular dependencies (verified via yarn check-circ-deps)
  • My PR includes TypeDoc comments for all new (or modified) public methods and classes. It also includes TypeDoc for large or complex private methods.
  • My PR passes all specs/tests and includes new/updated specs or tests based on the Code Testing Guide.
  • If my PR includes new libraries/dependencies (in package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.
  • If my PR includes new features or configurations, I've provided basic technical documentation in the PR itself.
  • If my PR fixes an issue ticket, I've linked them together.

@tdonohue tdonohue added bug 1 APPROVAL pull request only requires a single approval to merge port to main This PR needs to be ported to `main` branch for the next major release labels Apr 19, 2024
@tdonohue tdonohue reopened this Apr 25, 2024
@tdonohue tdonohue changed the base branch from dspace-7_x to main April 25, 2024 16:39
Copy link

Hi @oscar-escire,
Conflicts have been detected against the base branch.
Please resolve these conflicts as soon as you can. Thanks!

@tdonohue tdonohue changed the base branch from main to dspace-7_x April 25, 2024 16:40
@tdonohue
Copy link
Member

Somehow this PR got "out of sync" in GitHub and wasn't showing the commit that was added. So, I've briefly changed its base branch to main & then back to dspace-7_x. That appears to have fixed the odd display issue I was seeing in GitHub.

@kanasznagyzoltan
Copy link

We have tested and worked for us.

Before this PR it indeed does not allow for an LTD longer than 4 chars.
image

Using this PR:
image

image

image

Copy link
Member

@tdonohue tdonohue left a comment

Choose a reason for hiding this comment

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

@oscar-escire : I gave this a look today. The overall concept is correct, but I think we need to move this email pattern to a single location & reuse it everywhere it is needed.

For instance, I notice in this PR that you *modified the email pattern in the registration form. But I believe that email pattern already works (at least the registration form is working for longer TLDs on both demo & sandbox)

@@ -99,7 +99,7 @@ export class RegisterEmailFormComponent implements OnDestroy, OnInit {
Validators.email,
// Regex pattern borrowed from HTML5 specs for a valid email address:
// https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address
Validators.pattern('^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$')
Validators.pattern('^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@(?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])\\.(?:[a-zA-Z0-9](?:\\.[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$')
Copy link
Member

Choose a reason for hiding this comment

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

Why has this been modified? The pattern here is the same one noted in the HTML5 docs here: https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address

When I test this at https://demo.dspace.org/register, I've found that I already can add an email with a longer TLD. So, I think this pattern was already correct, and just needed to be copied elsewhere (or moved into a constant to be reused elsewhere)

Change patterns for form with email inputs
@VictorDuranEscire
Copy link

Hi @tdonohue, I updated the branch, based on the comments, I changed the current form pattern to the old one and moved it to a file with the patterns prefix for the forms. I hope these changes are what you expected

@tdonohue tdonohue self-requested a review June 14, 2024 17:00
Copy link
Member

@tdonohue tdonohue left a comment

Choose a reason for hiding this comment

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

@VictorDuranEscire and @oscar-escire : The new changes look better to me. However, this is now failing specs because the updated pattern is saying that test@test is a valid email address.

Here's the test that fails: https://github.com/DSpace/dspace-angular/blob/main/src/app/access-control/epeople-registry/eperson-form/eperson-form.component.spec.ts#L358-L361

Additional notes on the pattern inline below

@@ -0,0 +1,2 @@
//Patterns for form validations
export const VALID_EMAIL_PATTERN = "^[a-zA-Z0-9.!#$%&\\' * +\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$";
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't appear to be the same pattern we were using previously in the register-email-form.component.ts. Is there a reason you've changed it?

I think you need to update this pattern to be:

"^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$"

That value is copied directly from the register-email-form.component.ts and is the same as the HTML5 spec recommended JavaScript pattern at https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address

@VictorHugoDS13
Copy link

H! @tdonohue, I submitted a fix for the email pattern, the previously pattern fails on validate ("^[a-zA-Z0-9.!#$%&'+/=?^_`{|}~-]+@a-zA-Z0-9?(?:.a-zA-Z0-9?)$") emails as 'test@test' i verified this on demo page, i don't know why the pattern pass the unit tests.

@tdonohue tdonohue self-requested a review August 28, 2024 16:17
Copy link

Hi @oscar-escire,
Conflicts have been detected against the base branch.
Please resolve these conflicts as soon as you can. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 APPROVAL pull request only requires a single approval to merge bug merge conflict port to main This PR needs to be ported to `main` branch for the next major release
Projects
Status: 👀 Under Review
Development

Successfully merging this pull request may close these issues.

Not able to register EPerson account for email address with TLD of more than 4 characters
6 participants