Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 099481f

Browse filesBrowse files
Merge branch '3.4' into 4.4
* 3.4: [Http Foundation] Fix clear cookie samesite [Security] Check if firewall is stateless before checking for session/previous session [Form] Support customized intl php.ini settings [Security] Remember me: allow to set the samesite cookie flag [Debug] fix for PHP 7.3.16+/7.4.4+ [Validator] Backport translations Prevent warning in proc_open()
2 parents cd17611 + 438d9e5 commit 099481f
Copy full SHA for 099481f

17 files changed

+124
-18
lines changed

‎src/Symfony/Component/Debug/ErrorHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Debug/ErrorHandler.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ public function handleError($type, $message, $file, $line)
499499
if ($this->isRecursive) {
500500
$log = 0;
501501
} else {
502-
if (!\defined('HHVM_VERSION')) {
502+
if (\PHP_VERSION_ID < (\PHP_VERSION_ID < 70400 ? 70316 : 70404) && !\defined('HHVM_VERSION')) {
503503
$currentErrorHandler = set_error_handler('var_dump');
504504
restore_error_handler();
505505
}
@@ -511,7 +511,7 @@ public function handleError($type, $message, $file, $line)
511511
} finally {
512512
$this->isRecursive = false;
513513

514-
if (!\defined('HHVM_VERSION')) {
514+
if (\PHP_VERSION_ID < (\PHP_VERSION_ID < 70400 ? 70316 : 70404) && !\defined('HHVM_VERSION')) {
515515
set_error_handler($currentErrorHandler);
516516
}
517517
}

‎src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,6 @@ public function testHandleDeprecation()
329329
$handler = new ErrorHandler();
330330
$handler->setDefaultLogger($logger);
331331
@$handler->handleError(E_USER_DEPRECATED, 'Foo deprecation', __FILE__, __LINE__, []);
332-
333-
restore_error_handler();
334332
}
335333

336334
public function testHandleException()

‎src/Symfony/Component/ErrorHandler/ErrorHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/ErrorHandler/ErrorHandler.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ public function handleError(int $type, string $message, string $file, int $line)
519519
if ($this->isRecursive) {
520520
$log = 0;
521521
} else {
522-
if (!\defined('HHVM_VERSION')) {
522+
if (\PHP_VERSION_ID < (\PHP_VERSION_ID < 70400 ? 70316 : 70404)) {
523523
$currentErrorHandler = set_error_handler('var_dump');
524524
restore_error_handler();
525525
}
@@ -531,7 +531,7 @@ public function handleError(int $type, string $message, string $file, int $line)
531531
} finally {
532532
$this->isRecursive = false;
533533

534-
if (!\defined('HHVM_VERSION')) {
534+
if (\PHP_VERSION_ID < (\PHP_VERSION_ID < 70400 ? 70316 : 70404)) {
535535
set_error_handler($currentErrorHandler);
536536
}
537537
}

‎src/Symfony/Component/ErrorHandler/Tests/ErrorHandlerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/ErrorHandler/Tests/ErrorHandlerTest.php
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,6 @@ public function testHandleDeprecation()
363363
$handler = new ErrorHandler();
364364
$handler->setDefaultLogger($logger);
365365
@$handler->handleError(E_USER_DEPRECATED, 'Foo deprecation', __FILE__, __LINE__, []);
366-
367-
restore_error_handler();
368366
}
369367

370368
/**
@@ -618,6 +616,10 @@ public function errorHandlerWhenLoggingProvider(): iterable
618616

619617
public function testAssertQuietEval()
620618
{
619+
if ('-1' === ini_get('zend.assertions')) {
620+
$this->markTestSkipped('zend.assertions is forcibly disabled');
621+
}
622+
621623
$ini = [
622624
ini_set('zend.assertions', 1),
623625
ini_set('assert.active', 1),

‎src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,16 @@ public function reverseTransform($value)
117117
// date-only patterns require parsing to be done in UTC, as midnight might not exist in the local timezone due
118118
// to DST changes
119119
$dateOnly = $this->isPatternDateOnly();
120+
$dateFormatter = $this->getIntlDateFormatter($dateOnly);
120121

121-
$timestamp = $this->getIntlDateFormatter($dateOnly)->parse($value);
122+
try {
123+
$timestamp = @$dateFormatter->parse($value);
124+
} catch (\IntlException $e) {
125+
throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e);
126+
}
122127

123128
if (0 != intl_get_error_code()) {
124-
throw new TransformationFailedException(intl_get_error_message());
129+
throw new TransformationFailedException(intl_get_error_message(), intl_get_error_code());
125130
} elseif ($timestamp > 253402214400) {
126131
// This timestamp represents UTC midnight of 9999-12-31 to prevent 5+ digit years
127132
throw new TransformationFailedException('Years beyond 9999 are not supported.');

‎src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php
+46Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ protected function setUp(): void
2727
{
2828
parent::setUp();
2929

30+
// Normalize intl. configuration settings.
31+
if (\extension_loaded('intl')) {
32+
$this->iniSet('intl.use_exceptions', 0);
33+
$this->iniSet('intl.error_level', 0);
34+
}
35+
3036
// Since we test against "de_AT", we need the full implementation
3137
IntlTestHelper::requireFullIntl($this, '57.1');
3238

@@ -322,4 +328,44 @@ public function testReverseTransformFiveDigitYearsWithTimestamp()
322328
$transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', null, null, \IntlDateFormatter::GREGORIAN, 'yyyy-MM-dd HH:mm:ss');
323329
$transformer->reverseTransform('20107-03-21 12:34:56');
324330
}
331+
332+
public function testReverseTransformWrapsIntlErrorsWithErrorLevel()
333+
{
334+
if (!\extension_loaded('intl')) {
335+
$this->markTestSkipped('intl extension is not loaded');
336+
}
337+
338+
$this->iniSet('intl.error_level', E_WARNING);
339+
340+
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
341+
$transformer = new DateTimeToLocalizedStringTransformer();
342+
$transformer->reverseTransform('12345');
343+
}
344+
345+
public function testReverseTransformWrapsIntlErrorsWithExceptions()
346+
{
347+
if (!\extension_loaded('intl')) {
348+
$this->markTestSkipped('intl extension is not loaded');
349+
}
350+
351+
$this->iniSet('intl.use_exceptions', 1);
352+
353+
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
354+
$transformer = new DateTimeToLocalizedStringTransformer();
355+
$transformer->reverseTransform('12345');
356+
}
357+
358+
public function testReverseTransformWrapsIntlErrorsWithExceptionsAndErrorLevel()
359+
{
360+
if (!\extension_loaded('intl')) {
361+
$this->markTestSkipped('intl extension is not loaded');
362+
}
363+
364+
$this->iniSet('intl.use_exceptions', 1);
365+
$this->iniSet('intl.error_level', E_WARNING);
366+
367+
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
368+
$transformer = new DateTimeToLocalizedStringTransformer();
369+
$transformer->reverseTransform('12345');
370+
}
325371
}

‎src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,13 @@ public function getCookies($format = self::COOKIES_FLAT)
252252
* @param string $domain
253253
* @param bool $secure
254254
* @param bool $httpOnly
255+
* @param string $sameSite
255256
*/
256-
public function clearCookie($name, $path = '/', $domain = null, $secure = false, $httpOnly = true)
257+
public function clearCookie($name, $path = '/', $domain = null, $secure = false, $httpOnly = true/*, $sameSite = null*/)
257258
{
258-
$this->setCookie(new Cookie($name, null, 1, $path, $domain, $secure, $httpOnly, false, null));
259+
$sameSite = \func_num_args() > 5 ? func_get_arg(5) : null;
260+
261+
$this->setCookie(new Cookie($name, null, 1, $path, $domain, $secure, $httpOnly, false, $sameSite));
259262
}
260263

261264
/**

‎src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,14 @@ public function testClearCookieSecureNotHttpOnly()
128128
$this->assertSetCookieHeader('foo=deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; Max-Age=0; path=/; secure', $bag);
129129
}
130130

131+
public function testClearCookieSamesite()
132+
{
133+
$bag = new ResponseHeaderBag([]);
134+
135+
$bag->clearCookie('foo', '/', null, true, false, 'none');
136+
$this->assertSetCookieHeader('foo=deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; Max-Age=0; path=/; secure; samesite=none', $bag);
137+
}
138+
131139
public function testReplace()
132140
{
133141
$bag = new ResponseHeaderBag([]);

‎src/Symfony/Component/Process/Process.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Process/Process.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ public function start(callable $callback = null, array $env = [])
336336
throw new RuntimeException(sprintf('The provided cwd "%s" does not exist.', $this->cwd));
337337
}
338338

339-
$this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $envPairs, $options);
339+
$this->process = @proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $envPairs, $options);
340340

341341
if (!\is_resource($this->process)) {
342342
throw new RuntimeException('Unable to launch a new process.');

‎src/Symfony/Component/Security/Guard/GuardAuthenticatorHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Guard/GuardAuthenticatorHandler.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function setSessionAuthenticationStrategy(SessionAuthenticationStrategyIn
127127

128128
private function migrateSession(Request $request, TokenInterface $token, ?string $providerKey)
129129
{
130-
if (!$this->sessionStrategy || !$request->hasSession() || !$request->hasPreviousSession() || \in_array($providerKey, $this->statelessProviderKeys, true)) {
130+
if (\in_array($providerKey, $this->statelessProviderKeys, true) || !$this->sessionStrategy || !$request->hasSession() || !$request->hasPreviousSession()) {
131131
return;
132132
}
133133

‎src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,25 @@ public function testSessionStrategyIsNotCalledWhenStateless()
153153
$handler->authenticateWithToken($this->token, $this->request, 'some_provider_key');
154154
}
155155

156+
/**
157+
* @requires function \Symfony\Component\HttpFoundation\Request::setSessionFactory
158+
*/
159+
public function testSessionIsNotInstantiatedOnStatelessFirewall()
160+
{
161+
$sessionFactory = $this->getMockBuilder(\stdClass::class)
162+
->setMethods(['__invoke'])
163+
->getMock();
164+
165+
$sessionFactory->expects($this->never())
166+
->method('__invoke');
167+
168+
$this->request->setSessionFactory($sessionFactory);
169+
170+
$handler = new GuardAuthenticatorHandler($this->tokenStorage, $this->dispatcher, ['stateless_provider_key']);
171+
$handler->setSessionAuthenticationStrategy($this->sessionStrategy);
172+
$handler->authenticateWithToken($this->token, $this->request, 'stateless_provider_key');
173+
}
174+
156175
protected function setUp(): void
157176
{
158177
$this->tokenStorage = $this->getMockBuilder(TokenStorageInterface::class)->getMock();

‎src/Symfony/Component/Security/Http/RememberMe/AbstractRememberMeServices.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/RememberMe/AbstractRememberMeServices.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ abstract class AbstractRememberMeServices implements RememberMeServicesInterface
3939
protected $options = [
4040
'secure' => false,
4141
'httponly' => true,
42+
'samesite' => null,
4243
];
4344
private $providerKey;
4445
private $secret;
@@ -276,7 +277,7 @@ protected function cancelCookie(Request $request)
276277
$this->logger->debug('Clearing remember-me cookie.', ['name' => $this->options['name']]);
277278
}
278279

279-
$request->attributes->set(self::COOKIE_ATTR_NAME, new Cookie($this->options['name'], null, 1, $this->options['path'], $this->options['domain'], $this->options['secure'] ?? $request->isSecure(), $this->options['httponly'], false, $this->options['samesite'] ?? null));
280+
$request->attributes->set(self::COOKIE_ATTR_NAME, new Cookie($this->options['name'], null, 1, $this->options['path'], $this->options['domain'], $this->options['secure'] ?? $request->isSecure(), $this->options['httponly'], false, $this->options['samesite']));
280281
}
281282

282283
/**

‎src/Symfony/Component/Security/Http/RememberMe/PersistentTokenBasedRememberMeServices.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/RememberMe/PersistentTokenBasedRememberMeServices.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ protected function processAutoLoginCookie(array $cookieParts, Request $request)
8686
$this->options['secure'] ?? $request->isSecure(),
8787
$this->options['httponly'],
8888
false,
89-
$this->options['samesite'] ?? null
89+
$this->options['samesite']
9090
)
9191
);
9292

@@ -121,7 +121,7 @@ protected function onLoginSuccess(Request $request, Response $response, TokenInt
121121
$this->options['secure'] ?? $request->isSecure(),
122122
$this->options['httponly'],
123123
false,
124-
$this->options['samesite'] ?? null
124+
$this->options['samesite']
125125
)
126126
);
127127
}

‎src/Symfony/Component/Security/Http/RememberMe/TokenBasedRememberMeServices.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/RememberMe/TokenBasedRememberMeServices.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ protected function onLoginSuccess(Request $request, Response $response, TokenInt
8383
$this->options['secure'] ?? $request->isSecure(),
8484
$this->options['httponly'],
8585
false,
86-
$this->options['samesite'] ?? null
86+
$this->options['samesite']
8787
)
8888
);
8989
}

‎src/Symfony/Component/Validator/Resources/translations/validators.en.xlf

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Resources/translations/validators.en.xlf
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,14 @@
374374
<source>The number of elements in this collection should be a multiple of {{ compared_value }}.</source>
375375
<target>The number of elements in this collection should be a multiple of {{ compared_value }}.</target>
376376
</trans-unit>
377+
<trans-unit id="97">
378+
<source>This value should satisfy at least one of the following constraints:</source>
379+
<target>This value should satisfy at least one of the following constraints:</target>
380+
</trans-unit>
381+
<trans-unit id="98">
382+
<source>Each element of this collection should satisfy its own set of constraints.</source>
383+
<target>Each element of this collection should satisfy its own set of constraints.</target>
384+
</trans-unit>
377385
</body>
378386
</file>
379387
</xliff>

‎src/Symfony/Component/Validator/Resources/translations/validators.es.xlf

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Resources/translations/validators.es.xlf
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,14 @@
374374
<source>The number of elements in this collection should be a multiple of {{ compared_value }}.</source>
375375
<target>El número de elementos en esta colección debería ser múltiplo de {{ compared_value }}.</target>
376376
</trans-unit>
377+
<trans-unit id="97">
378+
<source>This value should satisfy at least one of the following constraints:</source>
379+
<target>Este valor debería satisfacer al menos una de las siguientes restricciones:</target>
380+
</trans-unit>
381+
<trans-unit id="98">
382+
<source>Each element of this collection should satisfy its own set of constraints.</source>
383+
<target>Cada elemento de esta colección debería satisfacer su propio conjunto de restricciones.</target>
384+
</trans-unit>
377385
</body>
378386
</file>
379387
</xliff>

‎src/Symfony/Component/Validator/Resources/translations/validators.pl.xlf

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Resources/translations/validators.pl.xlf
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,14 @@
374374
<source>The number of elements in this collection should be a multiple of {{ compared_value }}.</source>
375375
<target>Liczba elementów w tym zbiorze powinna być wielokrotnością {{ compared_value }}.</target>
376376
</trans-unit>
377+
<trans-unit id="97">
378+
<source>This value should satisfy at least one of the following constraints:</source>
379+
<target>Ta wartość powinna spełniać co najmniej jedną z następujących reguł:</target>
380+
</trans-unit>
381+
<trans-unit id="98">
382+
<source>Each element of this collection should satisfy its own set of constraints.</source>
383+
<target>Każdy element w tym zbiorze powinien spełniać własny zestaw reguł.</target>
384+
</trans-unit>
377385
</body>
378386
</file>
379387
</xliff>

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.