70855[TASK] Add early check for validating email address
Commit message
Review
-
Code review CR +2 Done
- Andreas Kienast +2
- Oliver Klee +1
- Stephan Großberndt +1
- Wouter Wolters +1
-
Verified V +2 Done
- Andreas Kienast +2
- Stephan Großberndt +1
- Wouter Wolters +1
- core-ci +1 CI
Issues 1
Files 1
Review log 1718
-
Georg Ringer uploaded patch set 1 09/01/21, 09:22
-
Georg Ringer commented on patch set 1 V +1 CR +1 09/01/21, 09:22
This change is ready for review. -
Georg Ringer voted on patch set 1 V 0 CR 0 09/01/21, 09:23
-
core-ci voted on patch set 1 V +1 09/01/21, 09:36 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15994
-
Christian Kuhn commented on patch set 1 CR -1 09/01/21, 09:40
Didn't we deny a very similar patch recently? IIRC I had a look at this and the casual configuration is that the first basic test of the library checks for @ at a very early point and returns false. -
Christian Kuhn commented on patch set 1 09/01/21, 09:43
-
Stephan Großberndt commented on patch set 1 09/01/21, 16:27
See comment by issue reporter: "For validation we use the 3rd party library egulias/email-validator. With blackfire I determined that this library is quite costly in terms of memory and wall time." -
Benni Mack wrote 09/07/21, 10:17
Removed reviewer Benni Mack. -
Christian Kuhn commented on patch set 1 09/11/21, 15:10
Reply
Yes. I think we solved that in master with https://review.typo3.org/c/Packages/TYPO3.CMS/+/68879: The API is slightly different in v10, so we couldn't add that patch to v10. I'm fine with adding the "check for @ sign" hack in v10, though, but master should not suffer from that issue at all after https://review.typo3.org/c/Packages/TYPO3.CMS/+/68879 has been merged. So: Drop patch for v11 and target to v10 only? What do you think? -
Stephan Großberndt commented on patch set 1 09/22/21, 20:44
Reply Unresolved
Behaviour is not different in master than in v10. v10 only uses RFCValidation https://gitlab.typo3.org/typo3/typo3/-/blob/10.4/typo3/sysext/core/Classes/Utility/GeneralUtility.php#L847 while master additionally allows multiple validators (but falls back to RFCValidation and has RFCValidation as default as well): https://gitlab.typo3.org/typo3/typo3/-/blob/master/typo3/sysext/core/Classes/Utility/GeneralUtility.php#L808 The master change you mention only makes sure validation fails with the first failing validator instead of executing all of them. It is costly because for each (!) validEmail() check the following objects are created: - a new EmailValidator object - a new EmailLexer object (in EmailValidator constructor) - a new RFCValidation object - a new EmailParser object (in RFCValidation isValid()) - a new LocalPart object (in EmailParser constructor) - a new DomainPart object (in EmailParser constructor) - a heavy non-email-related regex in AbstractLexer->scan() https://github.com/doctrine/lexer/blob/1.3.x/lib/Doctrine/Common/Lexer/AbstractLexer.php#L255 Localpart scans char by char until it finds the @ sign, which is not part of the URL string. While bringing back that error even more objects for the error are created. I will not list them. In master due to the multiple validators loop even RFCValidation is checked with "instanceof EmailValidation" egulias/EmailValidator does a great job in thoroughly checking an email address and finding flaws but I *really* think a strpos('@') is a sensible pre-check before starting that machine.. -
Oliver Klee voted on patch set 1 CR +1 09/22/21, 21:57
-
Stephan Großberndt voted on patch set 1 V +1 CR +1 09/23/21, 07:03
-
Wouter Wolters voted on patch set 1 V +1 CR +1 09/23/21, 08:15
-
Christian Kuhn commented on patch set 1 CR 0 09/24/21, 11:17
Thx for your analysis. When I had a look at the code, my impression was the string check that includes the @ sign is the library is rather low-hanging and quick. But I may be wrong. This simple early @ check is ugly, but straight and not harmful. I'll step back here and remove my -1. Thanks for investigation. -
Andreas Kienast voted on patch set 1 CR +1 09/24/21, 13:21
-
Andreas Kienast voted on patch set 1 V +2 CR +2 09/24/21, 13:27
-
Andreas Kienast merged patch set 2 09/24/21, 13:28
-
Simon Schaufelberger commented on patch set 2 09/24/21, 13:40
a `str_contains()` (PHP 8) would have been even better