Skip to content

Commit 98a7937

Browse files
Merge branch '4.4' into 5.4
* 4.4: MailerInterface: failed exception contract when enabling messenger add nonces to profiler
2 parents d2ab9cf + 65e6faa commit 98a7937

File tree

4 files changed

+23
-10
lines changed

4 files changed

+23
-10
lines changed

src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function panelAction(Request $request, string $token): Response
8383
}
8484

8585
if (!$profile = $this->profiler->loadProfile($token)) {
86-
return new Response($this->twig->render('@WebProfiler/Profiler/info.html.twig', ['about' => 'no_token', 'token' => $token, 'request' => $request]), 200, ['Content-Type' => 'text/html']);
86+
return $this->renderWithCspNonces($request, '@WebProfiler/Profiler/info.html.twig', ['about' => 'no_token', 'token' => $token, 'request' => $request]);
8787
}
8888

8989
if (null === $panel) {
@@ -106,7 +106,7 @@ public function panelAction(Request $request, string $token): Response
106106
throw new NotFoundHttpException(sprintf('Panel "%s" is not available for token "%s".', $panel, $token));
107107
}
108108

109-
return new Response($this->twig->render($this->getTemplateManager()->getName($profile, $panel), [
109+
return $this->renderWithCspNonces($request, $this->getTemplateManager()->getName($profile, $panel), [
110110
'token' => $token,
111111
'profile' => $profile,
112112
'collector' => $profile->getCollector($panel),
@@ -116,7 +116,7 @@ public function panelAction(Request $request, string $token): Response
116116
'templates' => $this->getTemplateManager()->getNames($profile),
117117
'is_ajax' => $request->isXmlHttpRequest(),
118118
'profiler_markup_version' => 2, // 1 = original profiler, 2 = Symfony 2.8+ profiler
119-
]), 200, ['Content-Type' => 'text/html']);
119+
]);
120120
}
121121

122122
/**
@@ -238,7 +238,7 @@ public function searchResultsAction(Request $request, string $token): Response
238238
$end = $request->query->get('end', null);
239239
$limit = $request->query->get('limit');
240240

241-
return new Response($this->twig->render('@WebProfiler/Profiler/results.html.twig', [
241+
return $this->renderWithCspNonces($request, '@WebProfiler/Profiler/results.html.twig', [
242242
'request' => $request,
243243
'token' => $token,
244244
'profile' => $profile,
@@ -251,7 +251,7 @@ public function searchResultsAction(Request $request, string $token): Response
251251
'end' => $end,
252252
'limit' => $limit,
253253
'panel' => null,
254-
]), 200, ['Content-Type' => 'text/html']);
254+
]);
255255
}
256256

257257
/**
@@ -347,11 +347,11 @@ public function openAction(Request $request): Response
347347
throw new NotFoundHttpException(sprintf('The file "%s" cannot be opened.', $file));
348348
}
349349

350-
return new Response($this->twig->render('@WebProfiler/Profiler/open.html.twig', [
350+
return $this->renderWithCspNonces($request, '@WebProfiler/Profiler/open.html.twig', [
351351
'filename' => $filename,
352352
'file' => $file,
353353
'line' => $line,
354-
]), 200, ['Content-Type' => 'text/html']);
354+
]);
355355
}
356356

357357
/**

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
<link rel="icon" type="image/x-icon" sizes="16x16" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAFEUlEQVR4AZVXA4wm2RMf27bXDM/+3/+sYBGfrbVtezc6BWtzfPbYXtvDL9906t6v0vWl05me7q1JzXuvvu4yXnvZgJ9hH6bwZYXLFR739vauUGuDwhq1L1N4Uv/tRYUhFjwcg49hn6aYr1V4TiGp86CoP9Oh1tV414KnM6t9fHymKUZ3DAI0hW4b1AyK3lE8phh5OxWeoJgUGhi5mLm95YzBwcHuhIQEV1JSEoWGhoKWHxYWFmenhJ/B5W0GwZpDt5Ovry9lZWWRyWOu5ORk7JsUpogsq5gnmISTU+HKQoLFQv/qq6/os88+I+EVFRUlSsRZ5oRiVmwlXMWShQkahUdERJCfnx/vd+3aRTU1NXTixAmqrq6mK1eu0PTp05mnrmD+QK6XhLO0XP2O2FJAQICRjjMU4P1PP/1EfX19NGfOHM8Z0N7ezueQkBBXYGAgSWIaQ5Em2T5QzFNSUig9PV3OHOe4uDjZ87p//34C7Nm7x/NcRUUFAX799Vec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WKkSaNSlojldoLF7TEP+nUEmKI62y1kOBINbVaNarcI0PuGGUlHyfYvLHg7/jhFSFYqZh0P8KHSptd5ksOPU3tvqAEUot/hFmOIYJLp87wGe9Dwm95eg5xa/R8G6d8U5EcFhwAAAABJRU5ErkJggg==">
99

1010
{% block head %}
11-
<style>
11+
<style{% if csp_style_nonce is defined and csp_style_nonce %} nonce="{{ csp_style_nonce }}"{% endif %}">
1212
{{ include('@WebProfiler/Profiler/profiler.css.twig') }}
1313
</style>
1414
{% endblock %}
1515
</head>
1616
<body>
17-
<script>
17+
<script{% if csp_script_nonce is defined and csp_script_nonce %} nonce="{{ csp_script_nonce }}"{% endif %}">
1818
if (null === localStorage.getItem('symfony/profiler/theme') || 'theme-auto' === localStorage.getItem('symfony/profiler/theme')) {
1919
document.body.classList.add((matchMedia('(prefers-color-scheme: dark)').matches ? 'theme-dark' : 'theme-light'));
2020
// needed to respond dynamically to OS changes without having to refresh the page

src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,8 @@ public function testSearchResultsAction($withCsp)
285285
'limit' => 2,
286286
'panel' => null,
287287
'request' => $request,
288+
'csp_script_nonce' => $withCsp ? 'dummy_nonce' : null,
289+
'csp_style_nonce' => $withCsp ? 'dummy_nonce' : null,
288290
]));
289291

290292
$response = $controller->searchResultsAction($request, 'empty');

src/Symfony/Component/Mailer/Mailer.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
use Symfony\Component\EventDispatcher\Event;
1616
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
1717
use Symfony\Component\Mailer\Event\MessageEvent;
18+
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
1819
use Symfony\Component\Mailer\Messenger\SendEmailMessage;
1920
use Symfony\Component\Mailer\Transport\TransportInterface;
21+
use Symfony\Component\Messenger\Exception\HandlerFailedException;
2022
use Symfony\Component\Messenger\MessageBusInterface;
2123
use Symfony\Component\Mime\RawMessage;
2224
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface as SymfonyEventDispatcherInterface;
@@ -52,6 +54,15 @@ public function send(RawMessage $message, Envelope $envelope = null): void
5254
$this->dispatcher->dispatch($event);
5355
}
5456

55-
$this->bus->dispatch(new SendEmailMessage($message, $envelope));
57+
try {
58+
$this->bus->dispatch(new SendEmailMessage($message, $envelope));
59+
} catch (HandlerFailedException $e) {
60+
foreach ($e->getNestedExceptions() as $nested) {
61+
if ($nested instanceof TransportExceptionInterface) {
62+
throw $nested;
63+
}
64+
}
65+
throw $e;
66+
}
5667
}
5768
}

0 commit comments

Comments
 (0)