Skip to content

Commit

Permalink
[BUGFIX] Catch UnknownLinkHandlerException in view helper
Browse files Browse the repository at this point in the history
EXT:redirect is using the TargetPageIdViewHelper to
get the page ID from a "t3://page?uid=" link. If this link
is however somehow malformed, e.g. "t3://page=uid=",
this previously lead to an exception being thrown, making
the redirects module unusable for an editor. Since an
editor usually does not have access to pid=0, it needed
an administrator to make the module accessible again.

This is now fixed by catching this exception in the
view helper.

Resolves: #95488
Releases: master, 10.4
Change-Id: I27625f22a8b6f6a197402742c781d5fe8adae7e4
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/71500
Tested-by: core-ci <typo3@b13.com>
Tested-by: Sybille Peters <sypets@gmx.de>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Sybille Peters <sypets@gmx.de>
Reviewed-by: Benni Mack <benni@typo3.org>
  • Loading branch information
o-ba authored and bmack committed Oct 8, 2021
1 parent e2c06db commit 0b9d925
Showing 1 changed file with 2 additions and 1 deletion.
Expand Up @@ -17,6 +17,7 @@

namespace TYPO3\CMS\Redirects\ViewHelpers;

use TYPO3\CMS\Core\LinkHandling\Exception\UnknownLinkHandlerException;
use TYPO3\CMS\Core\LinkHandling\Exception\UnknownUrnException;
use TYPO3\CMS\Core\LinkHandling\LinkService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand Down Expand Up @@ -54,7 +55,7 @@ public static function renderStatic(array $arguments, \Closure $renderChildrenCl
$linkService = GeneralUtility::makeInstance(LinkService::class);
$resolvedLink = $linkService->resolveByStringRepresentation($arguments['target']);
return $resolvedLink['pageuid'] ?? '';
} catch (UnknownUrnException $e) {
} catch (UnknownUrnException|UnknownLinkHandlerException $e) {
return '';
}
}
Expand Down

0 comments on commit 0b9d925

Please sign in to comment.