Skip to content

Commit 86898a6

Browse files
[HttpKernel] Check controllers are allowed when using the fallback surrogate strategy
1 parent caf41fc commit 86898a6

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/Symfony/Component/HttpKernel/Fragment/AbstractSurrogateFragmentRenderer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ public function __construct(?SurrogateInterface $surrogate, FragmentRendererInte
5959
public function render(string|ControllerReference $uri, Request $request, array $options = []): Response
6060
{
6161
if (!$this->surrogate || !$this->surrogate->hasSurrogateCapability($request)) {
62+
$request->attributes->set('_check_controller_is_allowed', -1); // @deprecated, switch to true in Symfony 7
63+
6264
if ($uri instanceof ControllerReference && $this->containsNonScalars($uri->attributes)) {
6365
throw new \InvalidArgumentException('Passing non-scalar values as part of URI attributes to the ESI and SSI rendering strategies is not supported. Use a different rendering strategy or pass scalar values.');
6466
}

src/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ protected function createSubRequest(string $uri, Request $request)
133133
if ($request->attributes->has('_stateless')) {
134134
$subRequest->attributes->set('_stateless', $request->attributes->get('_stateless'));
135135
}
136+
if ($request->attributes->has('_check_controller_is_allowed')) {
137+
$subRequest->attributes->set('_check_controller_is_allowed', $request->attributes->get('_check_controller_is_allowed'));
138+
}
136139

137140
return $subRequest;
138141
}

0 commit comments

Comments
 (0)