Bug #93890
closedMove email check in LegacyLinkNotationConverter to the end
100%
Description
Problem¶
On a page with many links the check validEmail()
in \TYPO3\CMS\Core\LinkHandling\LegacyLinkNotationConverter
(line 74) takes many server resources.
The check for validEmail
is at the beginning and mostly the link parameters are e.g. page UIDs (integer values).
So, the check will call some libraries and checks that will cost many resources.
Log output from typo3.org:
[09-Apr-2021 11:40:52 Europe/Berlin] PHP 191. TYPO3\CMS\Core\LinkHandling\LegacyLinkNotationConverter->resolve($linkParameter = '#transcript-1:02:56') /home/t3o-prod/ci/releases/26/private/typo3/sysext/core/Classes/LinkHandling/LinkService.php:87 [09-Apr-2021 11:40:52 Europe/Berlin] PHP 192. TYPO3\CMS\Core\Utility\GeneralUtility::validEmail($email = '') /home/t3o-prod/ci/releases/26/private/typo3/sysext/core/Classes/LinkHandling/LegacyLinkNotationConverter.php:74 [09-Apr-2021 11:40:52 Europe/Berlin] PHP 193. Egulias\EmailValidator\EmailValidator->isValid($email = '', $emailValidation = class Egulias\EmailValidator\Validation\RFCValidation { private $parser = class Egulias\EmailValidator\EmailParser { protected $warnings = [...]; protected $domainPart = ''; protected $localPart = ''; protected $lexer = class Egulias\EmailValidator\EmailLexer { ... }; protected $localPartParser = class Egulias\EmailValidator\Parser\LocalPart { ... }; protected $domainPartParser = class Egulias\EmailValidator\Parser\DomainPart { ... } }; private $warnings = []; private $error = NULL }) /home/t3o-prod/ci/releases/26/private/typo3/sysext/core/Classes/Utility/GeneralUtility.php:856 [09-Apr-2021 11:40:52 Europe/Berlin] PHP 194. Egulias\EmailValidator\Validation\RFCValidation->isValid($email = '', $emailLexer = class Egulias\EmailValidator\EmailLexer { protected $charValue = ['(' => 49, ')' => 261, '<' => 272, '>' => 273, '[' => 262, ']' => 263, ':' => 265, ';' => 275, '@' => 64, '\' => 92, '/' => 278, ',' => 274, '.' => 46, '\'' => 39, '`' => 96, '"' => 34, '-' => 264, '::' => 26' => 269, '67, ' ' => 268, ' ' => 270, ' ' => 301, 'IPv6' => 271, '{' => 276, '}' => 277, '' => NULL, '\0' => 0]; protected $hasInvalidTokens = FALSE; protected $previous = ['value' => '', 'type' => NULL, 'position' => 0]; public $token = ['value' => '', 'type' => NULL, 'position' => 0]; public $lookahead = NULL; private ${Doctrine\Common\Lexer\AbstractLexer}input = ''; private ${Doctrine\Common\Lexer\AbstractLexer}tokens = []; private ${Doctrine\Common\Lexer\AbstractLexer}position = 0; private ${Doctrine\Common\Lexer\AbstractLexer}peek = 0; private ${Doctrine\Common\Lexer\AbstractLexer}regex = '/([a-zA-Z_]+[46]?)|([^\\x00-\\x7F])|([0-9]+)|(\\r\\n)|(::)|(\\s+?)|(.)|[\\xA0-\\xff]+/iu' }) /home/t3o-prod/ci/releases/26/vendor/egulias/email-validator/src/EmailValidator.php:37 [09-Apr-2021 11:40:52 Europe/Berlin] PHP 195. Egulias\EmailValidator\EmailParser->parse($str = '') /home/t3o-prod/ci/releases/26/vendor/egulias/email-validator/src/Validation/RFCValidation.php:30 [09-Apr-2021 11:40:52 Europe/Berlin] PHP 196. Egulias\EmailValidator\Parser\DomainPart->parse($domainPart = '') /home/t3o-prod/ci/releases/26/vendor/egulias/email-validator/src/EmailParser.php:70 [09-Apr-2021 11:40:52 Europe/Berlin] PHP 197. Egulias\EmailValidator\Parser\DomainPart->performDomainStartChecks() /home/t3o-prod/ci/releases/26/vendor/egulias/email-validator/src/Parser/DomainPart.php:49 [09-Apr-2021 11:40:52 Europe/Berlin] PHP 198. Egulias\EmailValidator\Parser\DomainPart->checkEmptyDomain() /home/t3o-prod/ci/releases/26/vendor/egulias/email-validator/src/Parser/DomainPart.php:74
Solution¶
Move the check for a validEmail()
to the end and all checks for string comparisons like strpos()
to the begin.
It takes less resources checking if it's a page UID or anchors. The check for email address should be at the end.
Updated by Mathias Brodala over 3 years ago
- Related to Bug #92531: Email with php method as string is a valid address added
Updated by Georg Ringer over 3 years ago
- Status changed from New to Needs Feedback
problem is that a colon :
is technically valid inside an email address. So the check strpos($linkParameter, ':')
would change the behavior
Updated by Thomas Löffler over 3 years ago
But an @
is technical required for an email and could be checked before validEmail()
starts.
Updated by Thomas Löffler over 3 years ago
Also you can check if it's a number (page UID) or a section (starts with #
) before.
Updated by Gerrit Code Review over 3 years ago
- Status changed from Needs Feedback to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/68879
Updated by Gerrit Code Review over 3 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/68879
Updated by Gerrit Code Review about 3 years ago
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/68879
Updated by Gerrit Code Review about 3 years ago
Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/68879
Updated by Gerrit Code Review about 3 years ago
Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/68879
Updated by Gerrit Code Review about 3 years ago
Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/68879
Updated by Thomas Löffler about 3 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset b8dac1ae52a15a05f424dfad210ee8235cc7dbde.
Updated by Christian Kuhn almost 3 years ago
- Related to Bug #95042: email validation makes link generation unnecessary costly added