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

Change e-mail validation regex to accept subdomains with hyphens. #32240

Merged
merged 1 commit into from
Aug 8, 2018

Conversation

micbar
Copy link
Contributor

@micbar micbar commented Aug 6, 2018

Description

The filter regex which helps to validate the entered e-mail addresses does not accept subdomains with hyphens.

Steps to reproduce

  1. Configure ownCloud to allow Users to send notification emails while sharing
  2. Share something via public link
  3. Send link as e-mail
  4. Enter e-mail address

Expected behaviour

E-Mail address is being added to the field

Actual behaviour

Some E-Mail addresses with "-" charakter in the second subdomain get rejected / could not be added.

Examples - working

Examples - not working

Related Issue

  • Fixes owncloud/enterprise#2773

Motivation and Context

This has been discovered by a customer whose domains all contain a second subdomain with a hyphen

How Has This Been Tested?

  • this has been tested manually and
  • and within a regex tester.

New Regex, proposed solution

^[A-Za-z0-9\._%+-]+@(?:[A-Za-z0-9-]+\.)+[a-z]{2,}$

  • At the beginning of the string: all letters, numbers, dots, and %_+-charakters
  • @ charakter
  • after the @ charakter allow all numbers and letters and hyphens, but only single occurrances of dots, so ".." is not possible.
  • the toplevel domain must be 2 charakters at least.

Screenshots (if appropriate):

screenshot_2018-08-06 dateien - owncloud

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:

Open tasks:

  • Backport (if applicable set "backport-request" label and remove when the backport was done)

@codecov
Copy link

codecov bot commented Aug 6, 2018

Codecov Report

Merging #32240 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #32240      +/-   ##
============================================
+ Coverage     64.01%   64.01%   +<.01%     
  Complexity    18559    18559              
============================================
  Files          1171     1171              
  Lines         69834    69834              
  Branches       1267     1267              
============================================
+ Hits          44704    44706       +2     
+ Misses        24761    24758       -3     
- Partials        369      370       +1
Flag Coverage Δ Complexity Δ
#javascript 52.84% <100%> (+0.02%) 0 <0> (ø) ⬇️
#phpunit 65.29% <ø> (ø) 18559 <ø> (ø) ⬇️
Impacted Files Coverage Δ Complexity Δ
core/js/sharedialogmailview.js 62.37% <100%> (+1.98%) 0 <0> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 13b3d02...6585610. Read the comment docs.

@felixboehm
Copy link
Contributor

would this work?
[email protected]

@micbar
Copy link
Contributor Author

micbar commented Aug 6, 2018

@felixboehm
i checked your mail address. It will pass the check.

If you accidently put two dots in the address, it will fail verification.
[email protected]..xyz

@micbar
Copy link
Contributor Author

micbar commented Aug 6, 2018

@PVince81 after conversation in the chat, we need your feedback on this.

@micbar micbar requested a review from PVince81 August 6, 2018 11:08
@DeepDiver1975
Copy link
Member

I'd be happy to see a unit test covering the various samples of email addresses passing the regex.

@micbar micbar force-pushed the validate-email-regex branch from d51eeaf to 83b576d Compare August 6, 2018 14:16
Copy link
Member

@DeepDiver1975 DeepDiver1975 left a comment

Choose a reason for hiding this comment

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

squash commits please

@micbar micbar force-pushed the validate-email-regex branch from 8a591fa to 21100e1 Compare August 6, 2018 14:29
@micbar
Copy link
Contributor Author

micbar commented Aug 6, 2018

ok, i accidently committed the wrong file

@micbar
Copy link
Contributor Author

micbar commented Aug 6, 2018

complete mess :-(

@micbar micbar force-pushed the validate-email-regex branch from 21100e1 to 68e2810 Compare August 6, 2018 14:39
@micbar
Copy link
Contributor Author

micbar commented Aug 6, 2018

sorry for the noise...

@micbar micbar force-pushed the validate-email-regex branch from 68e2810 to 5ef7bee Compare August 6, 2018 15:02
Add tests, change regex to fail on umlauts.
@micbar micbar force-pushed the validate-email-regex branch from 5ef7bee to 6585610 Compare August 7, 2018 07:40
Copy link
Contributor

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

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

👍

@PVince81 PVince81 merged commit 5fb2067 into master Aug 8, 2018
@PVince81 PVince81 deleted the validate-email-regex branch August 8, 2018 14:12
@PVince81
Copy link
Contributor

PVince81 commented Aug 8, 2018

@micbar please backport to stable10

@phil-davis
Copy link
Contributor

Backport stable10 #32281

@lock lock bot locked as resolved and limited conversation to collaborators Aug 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants