Skip to content

Commit

Permalink
[BUGFIX] Use scheme://host:port of current request resolving error page
Browse files Browse the repository at this point in the history
Error pages in site configurations don't need to point to an absolute URI.
When such error pages get resolved, the scheme, host and port of the
request get attached to the resolved page.

Resolves: #86935
Releases: master, 9.5
Change-Id: I1b29b7e7ec51c67e6630ed0f2de5f7e3276e8e7d
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60873
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Benni Mack <benni@typo3.org>
  • Loading branch information
andreaskienast authored and bmack committed Jun 4, 2019
1 parent f364ea8 commit e7df51d
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public function handlePageError(ServerRequestInterface $request, string $message
$resolvedUrl = $this->resolveUrl($request, $this->errorHandlerConfiguration['errorContentSource']);
$content = null;
$report = [];

if ($resolvedUrl !== (string)$request->getUri()) {
$content = GeneralUtility::getUrl($resolvedUrl, 0, null, $report);
if ($content === false && ((int)$report['error'] === -1 || (int)$report['error'] > 200)) {
Expand Down Expand Up @@ -112,10 +113,28 @@ protected function resolveUrl(ServerRequestInterface $request, string $typoLinkU
if (!$language instanceof SiteLanguage || !$language->isEnabled()) {
$language = $site->getDefaultLanguage();
}

// Build Url
return (string)$site->getRouter()->generateUri(
$uri = $site->getRouter()->generateUri(
(int)$urlParams['pageuid'],
['_language' => $language]
);

// Fallback to the current URL if the site is not having a proper scheme and host
$currentUri = $request->getUri();
if (empty($uri->getScheme())) {
$uri = $uri->withScheme($currentUri->getScheme());
}
if (empty($uri->getUserInfo())) {
$uri = $uri->withUserInfo($currentUri->getUserInfo());
}
if (empty($uri->getHost())) {
$uri = $uri->withHost($currentUri->getHost());
}
if ($uri->getPort() === null) {
$uri = $uri->withPort($currentUri->getPort());
}

return (string)$uri;
}
}

0 comments on commit e7df51d

Please sign in to comment.