8000 Merge branch '6.1' into 6.2 · jeremyFreeAgent/symfony@beaef9e · GitHub
[go: up one dir, main page]

Skip to content

Commit beaef9e

Browse files
Merge branch '6.1' into 6.2
* 6.1: [HttpFoundation] IPv4-mapped IPv6 addresses incorrectly rejected Minor (comment only), part 2 [RateLimiter] Add typecast to Reservation::wait [FrameworkBundle] add `kernel.locale_aware` tag to `LocaleSwitcher` [FrameworkBundle] Remove check of undefined service in mailer assertions [VarDumper] Ignore \Error in __debugInfo()
2 parents 2ecb381 + c195e1d commit beaef9e

File tree

9 files changed

+32
-13
lines changed

9 files changed

+32
-13
lines changed

src/Symfony/Bundle/FrameworkBundle/Resources/config/translation.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,11 @@
186186
->set('translation.locale_switcher', LocaleSwitcher::class)
187187
->args([
188188
param('kernel.default_locale'),
189-
tagged_iterator('kernel.locale_aware'),
189+
tagged_iterator('kernel.locale_aware', exclude: 'translation.locale_switcher'),
190190
service('router.request_context')->ignoreOnInvalid(),
191191
])
192192
->tag('kernel.reset', ['method' => 'reset'])
193+
->tag('kernel.locale_aware')
193194
->alias(LocaleAwareInterface::class, 'translation.locale_switcher')
194195
->alias(LocaleSwitcher::class, 'translation.locale_switcher')
195196
;

src/Symfony/Bundle/FrameworkBundle/Test/MailerAssertionsTrait.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,6 @@ private static function getMessageMailerEvents(): MessageEvents
123123
return $container->get('mailer.message_logger_listener')->getEvents();
124124
}
125125

126-
if ($container->has('mailer.logger_message_listener')) {
127-
return $container->get('mailer.logger_message_listener')->getEvents();
128-
}
129-
130126
static::fail('A client must have Mailer enabled to make email assertions. Did you forget to require symfony/mailer?');
131127
}
132128
}

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
use Symfony\Component\DependencyInjection\ChildDefinition;
3838
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
3939
use Symfony\Component\DependencyInjection\Compiler\ResolveInstanceofConditionalsPass;
40+
use Symfony\Component\DependencyInjection\Compiler\ResolveTaggedIteratorArgumentPass;
4041
use Symfony\Component\DependencyInjection\ContainerBuilder;
4142
use Symfony\Component\DependencyInjection\ContainerInterface;
4243
use Symfony\Component\DependencyInjection\Definition;
@@ -2067,7 +2068,9 @@ public function testLocaleSwitcherServiceRegistered()
20672068
$this->markTestSkipped('LocaleSwitcher not available.');
20682069
}
20692070

2070-
$container = $this->createContainerFromFile('full');
2071+
$container = $this->createContainerFromFile('full', compile: false);
2072+
$container->addCompilerPass(new ResolveTaggedIteratorArgumentPass());
2073+
$container->compile();
20712074

20722075
$this->assertTrue($container->has('translation.locale_switcher'));
20732076

@@ -2077,6 +2080,10 @@ public function testLocaleSwitcherServiceRegistered()
20772080
$this->assertInstanceOf(TaggedIteratorArgument::class, $switcherDef->getArgument(1));
20782081
$this->assertSame('kernel.locale_aware', $switcherDef->getArgument(1)->getTag());
20792082
$this->assertEquals(new Reference('router.request_context', ContainerBuilder::IGNORE_ON_INVALID_REFERENCE), $switcherDef->getArgument(2));
2083+
2084+
$localeAwareServices = array_map(fn (Reference $r) => (string) $r, $switcherDef->getArgument(1)->getValues());
2085+
2086+
$this->assertNotContains('translation.locale_switcher', $localeAwareServices);
20802087
}
20812088

20822089
public function testHtmlSanitizer()

src/Symfony/Component/HttpFoundation/IpUtils.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,17 @@ public static function checkIp6(string $requestIp, string $ip): bool
114114
}
115115

116116
// Check to see if we were given a IP4 $requestIp or $ip by mistake
117-
if (str_contains($requestIp, '.') || str_contains($ip, '.')) {
118-
return self::$checkedIps[$cacheKey] = false;
119-
}
120-
121117
if (!filter_var($requestIp, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) {
122118
return self::$checkedIps[$cacheKey] = false;
123119
}
124120

125121
if (str_contains($ip, '/')) {
126122
[$address, $netmask] = explode('/', $ip, 2);
127123

124+
if (!filter_var($address, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) {
125+
return self::$checkedIps[$cacheKey] = false;
126+
}
127+
128128
if ('0' === $netmask) {
129129
return (bool) unpack('n*', @inet_pton($address));
130130
}
@@ -133,6 +133,10 @@ public static function checkIp6(string $requestIp, string $ip): bool
133133
return self::$checkedIps[$cacheKey] = false;
134134
}
135135
} else {
136+
if (!filter_var($ip, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) {
137+
return self::$checkedIps[$cacheKey] = false;
138+
}
139+
136140
$address = $ip;
137141
$netmask = 128;
138142
}

src/Symfony/Component/HttpFoundation/Tests/IpUtilsTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public function getIpv6Data()
7878
[false, '0.0.0.0/8', '::1'],
7979
[false, '::1', '127.0.0.1'],
8080
[false, '::1', '0.0.0.0/8'],
81+
[true, '::ffff:10.126.42.2', '::ffff:10.0.0.0/0'],
8182
];
8283
}
8384

src/Symfony/Component/RateLimiter/Reservation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ public function getRateLimit(): RateLimit
4545

4646
public function wait(): void
4747
{
48-
usleep($this->getWaitDuration() * 1e6);
48+
usleep((int) ($this->getWaitDuration() * 1e6));
4949
}
5050
}

src/Symfony/Component/Security/Core/User/UserInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function getRoles(): array;
5555
public function eraseCredentials();
5656

5757
/**
58-
* Returns the identifier for this user (e.g. its username or email address).
58+
* Returns the identifier for this user (e.g. username or email address).
5959
*/
6060
public function getUserIdentifier(): string;
6161
}

src/Symfony/Component/VarDumper/Caster/Caster.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static function castObject(object $obj, string $class, bool $hasDebugInfo
4747
if ($hasDebugInfo) {
4848
try {
4949
$debugInfo = $obj->__debugInfo();
50-
} catch (\Exception) {
50+
} catch (\Throwable) {
5151
// ignore failing __debugInfo()
5252
$hasDebugInfo = false;
5353
}

src/Symfony/Component/VarDumper/Tests/Caster/CasterTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,14 @@ public function testAnonymousClass()
175175
, $c
176176
);
177177
}
178+
179+
public function testTypeErrorInDebugInfo()
180+
{
181+
$this->assertDumpMatchesFormat('class@anonymous {}', new class() {
182+
public function __debugInfo(): array
183+
{
184+
return ['class' => \get_class(null)];
185+
}
186+
});
187+
}
178188
}

0 commit comments

Comments
 (0)
0