Project

General

Profile

Actions

Bug #93890

closed

Move email check in LegacyLinkNotationConverter to the end

Added by Thomas Löffler about 3 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2021-04-09
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
10
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

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.


Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Bug #92531: Email with php method as string is a valid addressClosedGeorg Ringer2020-10-06

Actions
Related to TYPO3 Core - Bug #95042: email validation makes link generation unnecessary costlyClosed2021-08-31

Actions
Actions

Also available in: Atom PDF