Skip to content

Commit 3dcfac0

Browse files
bnflolli42
authored andcommitted
[BUGFIX] Pass original extbase response object to form framework finishers
The original extbase response was passed as second parameter to ObjectManager->get() – that did effectively nothing. The second get() parameter is not a fallback parameter (as probably supposed by the author) but the first constructor argument (but Response has no constructor). Now, rather use a coalesce operator to use the original response or create an own, if required. Also handle the StopActionException in case no extbase response is available (e.g. when rendered through FluidTemplateContentObject). Due to this fixes the redirect finisher can be adapted to stop echo'ing the response content on it's own. Directly echo'ing the response content caused wrong Content-Length headers to be generated as the core didn't know that content has been echo'ed. (The redirect response contains both a header based redirect and html meta redirect; due to early echo that meta redirect is prepended to the regular html output, and is missing in the Content-Length calculation.) That casused certain server environments (e.g. gzip, keep-alive, proxy) and browsers (e.g. Android, Opera desktop) to display gzip compressed data as garbage in the browser. Resolves: #83822 Releases: master, 8.7 Change-Id: I4cb56e7626ea786d4b5265782b5940e60e3d2ec0 Reviewed-on: https://review.typo3.org/56048 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
1 parent f9d07db commit 3dcfac0

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

typo3/sysext/form/Classes/Domain/Finishers/RedirectFinisher.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ protected function redirectToUri(string $uri, int $delay = 0, int $statusCode =
130130
$this->response->setStatus($statusCode);
131131
$this->response->setHeader('Location', (string)$uri);
132132
}
133-
echo $this->response->shutdown();
134133
throw new StopActionException('redirectToUri', 1477070964);
135134
}
136135

typo3/sysext/form/Classes/ViewHelpers/RenderViewHelper.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,20 @@ public static function renderStatic(array $arguments, \Closure $renderChildrenCl
9595

9696
$factory = $renderingContext->getObjectManager()->get($factoryClass);
9797
$formDefinition = $factory->build($overrideConfiguration, $prototypeName);
98-
$response = $renderingContext->getObjectManager()->get(Response::class, $renderingContext->getControllerContext()->getResponse());
98+
$response = $renderingContext->getControllerContext()->getResponse() ?? $renderingContext->getObjectManager()->get(Response::class);
9999
$form = $formDefinition->bind($renderingContext->getControllerContext()->getRequest(), $response);
100+
101+
// If the controller context does not contain a response object, this viewhelper is used in a
102+
// fluid template rendered by the FluidTemplateContentObject. Handle the StopActionException
103+
// as there is no extbase dispatcher involved that catches that. */
104+
if ($renderingContext->getControllerContext()->getResponse() === null) {
105+
try {
106+
return $form->render();
107+
} catch (\TYPO3\CMS\Extbase\Mvc\Exception\StopActionException $exception) {
108+
return $response->shutdown();
109+
}
110+
}
111+
100112
return $form->render();
101113
}
102114
}

0 commit comments

Comments
 (0)