Skip to content

Commit be93a22

Browse files
Merge branch '5.0'
* 5.0: [VarDumper] fix for change in PHP 7.4.6 Added regression test for AccountStatusException behavior (ref #36822) [HttpClient] fix PHP warning + accept status code >= 600 [Security/Core] fix compat of `NativePasswordEncoder` with pre-PHP74 values of `PASSWORD_*` consts embed resource name in error message [FrameworkBundle] fix stringable annotation Change priority of KernelEvents::RESPONSE subscriber Fix register event listeners compiler pass Missing description in `messenger:setup-transports` command [Serializer] fix issue with PHP 8 [WebProfiler] Remove 'none' when appending CSP tokens [TwigBundle] FormExtension does not have a constructor anymore since sf 4.0 [Yaml] Fix escaped quotes in quoted multi-line string
2 parents a73523b + 241542e commit be93a22

File tree

19 files changed

+129
-26
lines changed

19 files changed

+129
-26
lines changed

src/Symfony/Bundle/FrameworkBundle/Secrets/SodiumVault.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class SodiumVault extends AbstractVault implements EnvVarLoaderInterface
2828
private $secretsDir;
2929

3030
/**
31-
* @param string|object|null $decryptionKey A string or a stringable object that defines the private key to use to decrypt the vault
32-
* or null to store generated keys in the provided $secretsDir
31+
* @param string|\Stringable|null $decryptionKey A string or a stringable object that defines the private key to use to decrypt the vault
32+
* or null to store generated keys in the provided $secretsDir
3333
*/
3434
public function __construct(string $secretsDir, $decryptionKey = null)
3535
{

src/Symfony/Bundle/TwigBundle/Resources/config/form.xml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@
66
<services>
77
<defaults public="false" />
88

9-
<service id="twig.extension.form" class="Symfony\Bridge\Twig\Extension\FormExtension">
10-
<argument type="collection">
11-
<argument type="service" id="service_container" />
12-
<argument>twig.form.renderer</argument>
13-
</argument>
14-
</service>
9+
<service id="twig.extension.form" class="Symfony\Bridge\Twig\Extension\FormExtension" />
1510

1611
<service id="twig.form.engine" class="Symfony\Bridge\Twig\Form\TwigRendererEngine">
1712
<argument>%twig.form.resources%</argument>

src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ private function updateCspHeaders(Response $response, array $nonces = []): array
133133
continue;
134134
}
135135

136+
if (['\'none\''] === $fallback) {
137+
// Fallback came from "default-src: 'none'"
138+
// 'none' is invalid if it's not the only expression in the source list, so we leave it out
139+
$fallback = [];
140+
}
141+
136142
$headers[$header][$type] = $fallback;
137143
}
138144
$ruleIsSet = true;

src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@ public function provideRequestAndResponsesForOnKernelResponse()
140140
$this->createResponse(['Content-Security-Policy' => 'default-src \'self\' domain.com; script-src \'self\' \'unsafe-inline\'; script-src-elem \'self\'; style-src \'self\' \'unsafe-inline\'; style-src-elem \'self\'', 'Content-Security-Policy-Report-Only' => 'default-src \'self\' domain-report-only.com; script-src \'self\' \'unsafe-inline\'; script-src-elem \'self\'; style-src \'self\' \'unsafe-inline\'; style-src-elem \'self\'']),
141141
['Content-Security-Policy' => 'default-src \'self\' domain.com; script-src \'self\' \'unsafe-inline\'; script-src-elem \'self\' \'unsafe-inline\' \'nonce-'.$nonce.'\'; style-src \'self\' \'unsafe-inline\'; style-src-elem \'self\' \'unsafe-inline\' \'nonce-'.$nonce.'\'', 'Content-Security-Policy-Report-Only' => 'default-src \'self\' domain-report-only.com; script-src \'self\' \'unsafe-inline\'; script-src-elem \'self\' \'unsafe-inline\' \'nonce-'.$nonce.'\'; style-src \'self\' \'unsafe-inline\'; style-src-elem \'self\' \'unsafe-inline\' \'nonce-'.$nonce.'\'', 'X-Content-Security-Policy' => null],
142142
],
143+
[
144+
$nonce,
145+
['csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce],
146+
$this->createRequest(),
147+
$this->createResponse(['Content-Security-Policy' => 'default-src \'none\'', 'Content-Security-Policy-Report-Only' => 'default-src \'none\'']),
148+
['Content-Security-Policy' => 'default-src \'none\'; script-src \'unsafe-inline\' \'nonce-'.$nonce.'\'; style-src \'unsafe-inline\' \'nonce-'.$nonce.'\'', 'Content-Security-Policy-Report-Only' => 'default-src \'none\'; script-src \'unsafe-inline\' \'nonce-'.$nonce.'\'; style-src \'unsafe-inline\' \'nonce-'.$nonce.'\'', 'X-Content-Security-Policy' => null],
149+
],
143150
[
144151
$nonce,
145152
['csp_script_nonce' => $nonce, 'csp_style_nonce' => $nonce],

src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ public function process(ContainerBuilder $container)
7171
return;
7272
}
7373

74+
$aliases = [];
75+
7476
if ($container->hasParameter($this->eventAliasesParameter)) {
7577
$aliases = $container->getParameter($this->eventAliasesParameter);
76-
$container->getParameterBag()->remove($this->eventAliasesParameter);
77-
} else {
78-
$aliases = [];
7978
}
79+
8080
$globalDispatcherDefinition = $container->findDefinition($this->dispatcherService);
8181

8282
foreach ($container->findTaggedServiceIds($this->listenerTag, true) as $id => $events) {

src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,17 +234,22 @@ public function testInvokableEventListener()
234234
public function testAliasedEventListener(): void
235235
{
236236
$container = new ContainerBuilder();
237-
$container->setParameter('event_dispatcher.event_aliases', [AliasedEvent::class => 'aliased_event']);
237+
$eventAliases = [AliasedEvent::class => 'aliased_event'];
238+
$container->setParameter('event_dispatcher.event_aliases', $eventAliases);
238239
$container->register('foo', InvokableListenerService::class)->addTag('kernel.event_listener', ['event' => AliasedEvent::class, 'method' => 'onEvent']);
239240
$container->register('bar', InvokableListenerService::class)->addTag('kernel.event_listener', ['event' => CustomEvent::class, 'method' => 'onEvent']);
240241
$container->register('event_dispatcher');
241242

242-
$eventAliasPass = new AddEventAliasesPass([CustomEvent::class => 'custom_event']);
243+
$customEventAlias = [CustomEvent::class => 'custom_event'];
244+
$eventAliasPass = new AddEventAliasesPass($customEventAlias);
243245
$eventAliasPass->process($container);
244246

245247
$registerListenersPass = new RegisterListenersPass();
246248
$registerListenersPass->process($container);
247249

250+
$this->assertTrue($container->hasParameter('event_dispatcher.event_aliases'));
251+
$this->assertSame(array_merge($eventAliases, $customEventAlias), $container->getParameter('event_dispatcher.event_aliases'));
252+
248253
$definition = $container->getDefinition('event_dispatcher');
249254
$expectedCalls = [
250255
[

src/Symfony/Component/HttpClient/Response/CurlResponse.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,15 @@ private static function parseHeaderLine($ch, string $data, array &$info, array &
312312
}
313313

314314
if ("\r\n" !== $data) {
315-
// Regular header line: add it to the list
316-
self::addResponseHeaders([substr($data, 0, -2)], $info, $headers);
315+
try {
316+
// Regular header line: add it to the list
317+
self::addResponseHeaders([substr($data, 0, -2)], $info, $headers);
318+
} catch (TransportException $e) {
319+
$multi->handlesActivity[$id][] = null;
320+
$multi->handlesActivity[$id][] = $e;
321+
322+
return \strlen($data);
323+
}
317324

318325
if (0 !== strpos($data, 'HTTP/')) {
319326
if (0 === stripos($data, 'Location:')) {

src/Symfony/Component/HttpClient/Response/ResponseTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ private static function initialize(self $response): void
253253
private static function addResponseHeaders(array $responseHeaders, array &$info, array &$headers, string &$debug = ''): void
254254
{
255255
foreach ($responseHeaders as $h) {
256-
if (11 <= \strlen($h) && '/' === $h[4] && preg_match('#^HTTP/\d+(?:\.\d+)? ([12345]\d\d)(?: |$)#', $h, $m)) {
256+
if (11 <= \strlen($h) && '/' === $h[4] && preg_match('#^HTTP/\d+(?:\.\d+)? ([1-9]\d\d)(?: |$)#', $h, $m)) {
257257
if ($headers) {
258258
$debug .= "< \r\n";
259259
$headers = [];

src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function onKernelTerminate(TerminateEvent $event)
119119
public static function getSubscribedEvents(): array
120120
{
121121
return [
122-
KernelEvents::RESPONSE => ['onKernelResponse', -100],
122+
KernelEvents::RESPONSE => ['onKernelResponse', -1012],
123123
KernelEvents::EXCEPTION => ['onKernelException', 0],
124124
KernelEvents::TERMINATE => ['onKernelTerminate', -1024],
125125
];

src/Symfony/Component/Messenger/Command/SetupTransportsCommand.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ protected function configure()
4141
{
4242
$this
4343
->addArgument('transport', InputArgument::OPTIONAL, 'Name of the transport to setup', null)
44+
->setDescription('Prepares the required infrastructure for the transport')
4445
->setHelp(<<<EOF
4546
The <info>%command.name%</info> command setups the transports:
4647

0 commit comments

Comments
 (0)