Project

General

Profile

Actions

Bug #92230

closed

Linkvalidator ExternalLinktype preprocessing fails and terminates link crawling with some URLs

Added by Sybille Peters over 3 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Linkvalidator
Target version:
-
Start date:
2020-09-08
Due date:
% Done:

100%

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

Description

I had the scheduler task fail and abort because in one content block there was a URL such as:

<a href="mailto:http://example.org">URL causes exception</a>

This link is not correct, but I think one error should not cause link checking to abort.

This is the error from the log:

Tue, 08 Sep 2020 06:01:49 +0200 [ERROR] request="a0690b01ea8ec" component="TYPO3.CMS.Scheduler.Task.AbstractTask": 
Task failed to execute successfully. Class: TYPO3\CMS\Linkvalidator\Task\ValidatorTask, UID: 36, Code: 0, 
Argument 1 passed to TYPO3\CMS\Core\Utility\HttpUtility::idn_to_ascii() must be of the type string, null given, 
called in /var/www/mysite/htdocs/typo3/sysext/linkvalidator/Classes/Linktype/ExternalLinktype.php on line 225 - {"exception":{},"context":true}

The reason is that the 'host' is not filled on parse_url() for that URL.

For master, catching exceptions was completely removed in ExternalLinktype::preprossURL(). Don't know why.

For TYPO3 9, there is a catch block, but it should be catch Throwable for TYPO3 7, instead of just catch \Exception:

catch (\Exception $e) {
    // in case of any error, return empty url.
    $this->errorParams['errorType'] = 'exception';
    $this->errorParams['exception'] = $e->getMessage();
    $this->errorParams['message'] = $this->getErrorMessage($this->errorParams);
    return '';
} catch (\Throwable $e) { // For PHP 7
    // handle $e ...
    return $url;
}

Also, the function should handle empty $parts['hosts'] gracefully.

And if the URL can't be converted or there is some error, it is probably better to return the original URL instead of an empty string. That way we will get useful results when checking this URL.

Releases

Error occurs in 9.5.20, 10.4 and master (11).


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #92868: linkvalidator: HttpUtility::idn_to_ascii() throws ExceptionClosedSybille Peters2020-11-18

Actions
Actions

Also available in: Atom PDF