Skip to content

Commit c87fabb

Browse files
committed
Merge branch '6.4' into 7.3
* 6.4: [String] Fix nodes singular [Console] Fix testing multiline question [Security][Validator] Review translations. [Security] Ignore target route when exiting impersonation
2 parents 211aaa4 + 5c143ba commit c87fabb

File tree

9 files changed

+36
-5
lines changed

9 files changed

+36
-5
lines changed

src/Symfony/Component/Console/Helper/QuestionHelper.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,12 +516,16 @@ private function readInput($inputStream, Question $question): string|false
516516
$ret = '';
517517
$cp = $this->setIOCodepage();
518518
while (false !== ($char = fgetc($multiLineStreamReader))) {
519-
if (\PHP_EOL === "{$ret}{$char}") {
519+
if ("\x4" === $char || \PHP_EOL === "{$ret}{$char}") {
520520
break;
521521
}
522522
$ret .= $char;
523523
}
524524

525+
if (stream_get_meta_data($inputStream)['seekable']) {
526+
fseek($inputStream, ftell($multiLineStreamReader));
527+
}
528+
525529
return $this->resetIOCodepage($cp, $ret);
526530
}
527531

src/Symfony/Component/Console/Tester/TesterTrait.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ private static function createStream(array $inputs)
169169

170170
foreach ($inputs as $input) {
171171
fwrite($stream, $input.\PHP_EOL);
172+
173+
if (str_contains($input, \PHP_EOL)) {
174+
fwrite($stream, "\x4");
175+
}
172176
}
173177

174178
rewind($stream);

src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ public function testAskMultilineResponseWithWithCursorInMiddleOfSeekableInputStr
519519
$question->setMultiline(true);
520520

521521
$this->assertSame("some\ninput", $dialog->ask($this->createStreamableInputInterfaceMock($response), $this->createOutputInterface(), $question));
522-
$this->assertSame(8, ftell($response));
522+
$this->assertSame(18, ftell($response));
523523
}
524524

525525
/**

src/Symfony/Component/Security/Core/Resources/translations/security.es.xlf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
</trans-unit>
7777
<trans-unit id="20">
7878
<source>Too many failed login attempts, please try again in %minutes% minutes.</source>
79-
<target state="needs-review-translation">Demasiados intentos fallidos de inicio de sesión, inténtelo de nuevo en %minutes% minutos.</target>
79+
<target>Demasiados intentos fallidos de inicio de sesión, inténtelo de nuevo en %minutes% minutos.</target>
8080
</trans-unit>
8181
</body>
8282
</file>

src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function authenticate(RequestEvent $event): void
111111
if (!$this->stateless) {
112112
$request->query->remove($this->usernameParameter);
113113
$request->server->set('QUERY_STRING', http_build_query($request->query->all(), '', '&'));
114-
$response = new RedirectResponse($this->urlGenerator && $this->targetRoute ? $this->urlGenerator->generate($this->targetRoute) : $request->getUri(), 302);
114+
$response = new RedirectResponse($this->urlGenerator && $this->targetRoute && self::EXIT_VALUE !== $username ? $this->urlGenerator->generate($this->targetRoute) : $request->getUri(), 302);
115115

116116
$event->setResponse($response);
117117
}

src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\HttpFoundation\Request;
1818
use Symfony\Component\HttpKernel\Event\RequestEvent;
1919
use Symfony\Component\HttpKernel\HttpKernelInterface;
20+
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
2021
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
2122
use Symfony\Component\Security\Core\Authentication\Token\SwitchUserToken;
2223
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
@@ -109,6 +110,20 @@ public function testExitUserUpdatesToken()
109110
$this->assertSame($originalToken, $this->tokenStorage->getToken());
110111
}
111112

113+
public function testExitUserDoesNotRedirectToTargetRoute()
114+
{
115+
$originalToken = new UsernamePasswordToken(new InMemoryUser('username', '', []), 'key', []);
116+
$this->tokenStorage->setToken(new SwitchUserToken(new InMemoryUser('username', '', ['ROLE_USER']), 'key', ['ROLE_USER'], $originalToken));
117+
118+
$this->request->query->set('_switch_user', SwitchUserListener::EXIT_VALUE);
119+
120+
$listener = new SwitchUserListener($this->tokenStorage, $this->userProvider, $this->userChecker, 'provider123', $this->accessDecisionManager, urlGenerator: $this->createMock(UrlGeneratorInterface::class), targetRoute: 'whatever');
121+
$listener($this->event);
122+
123+
$this->assertInstanceOf(RedirectResponse::class, $this->event->getResponse());
124+
$this->assertSame($this->request->getUri(), $this->event->getResponse()->getTargetUrl());
125+
}
126+
112127
public function testExitUserDispatchesEventWithRefreshedUser()
113128
{
114129
$originalUser = new InMemoryUser('username', null);

src/Symfony/Component/String/Inflector/EnglishInflector.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ final class EnglishInflector implements InflectorInterface
2525
// Fourth entry: Whether the suffix may succeed a consonant
2626
// Fifth entry: singular suffix, normal
2727

28+
// nodes (node)
29+
['sedon', 5, true, true, 'node'],
30+
2831
// bacteria (bacterium)
2932
['airetcab', 8, true, true, 'bacterium'],
3033

@@ -202,6 +205,9 @@ final class EnglishInflector implements InflectorInterface
202205
// Fourth entry: Whether the suffix may succeed a consonant
203206
// Fifth entry: plural suffix, normal
204207

208+
// nodes (node)
209+
['edon', 4, true, true, 'nodes'],
210+
205211
// axes (axis)
206212
['sixa', 4, false, false, 'axes'],
207213

src/Symfony/Component/String/Tests/Inflector/EnglishInflectorTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ public static function singularizeProvider()
123123
['nebulae', 'nebula'],
124124
['neuroses', ['neuros', 'neurose', 'neurosis']],
125125
['news', 'news'],
126+
['nodes', 'node'],
126127
['oases', ['oas', 'oase', 'oasis']],
127128
['objectives', 'objective'],
128129
['outages', 'outage'],
@@ -281,6 +282,7 @@ public static function pluralizeProvider()
281282
['nebula', 'nebulae'],
282283
['neurosis', 'neuroses'],
283284
['news', 'news'],
285+
['node', 'nodes'],
284286
['oasis', 'oases'],
285287
['objective', 'objectives'],
286288
['ox', 'oxen'],

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@
468468
</trans-unit>
469469
<trans-unit id="121">
470470
<source>This value is not a valid Twig template.</source>
471-
<target state="needs-review-translation">Este valor no es una plantilla Twig válida.</target>
471+
<target>Este valor no es una plantilla Twig válida.</target>
472472
</trans-unit>
473473
</body>
474474
</file>

0 commit comments

Comments
 (0)