Skip to content

Commit ee1b504

Browse files
committedJan 17, 2025
Merge branch '7.1' into 7.2
* 7.1: (34 commits) improve amqp connection issues [Serializer] [ObjectNormalizer] Filter int when using FILTER_BOOL Fix #53778 [PropertyInfo] Add missing test fix tests [Security][Validators] Review translations. [validator] Updated Dutch translation [FrameworkBundle] Fix wiring ConsoleProfilerListener [HttpKernel] Fix link to php doc [Validator] Update sr_Cyrl 120:This value is not a valid slug. [Validator] Update sr_Latn 120:This value is not a valid slug. 6.4 Missing translations for Italian (it) #59419 tests(notifier): avoid failing SNS test with local AWS configuration Fix typo ratio comment chore: PropertyAccess - fix typo in DocBlock [Validator] Missing translations for Brazilian Portuguese (pt_BR) fix(dependency-injection): reset env vars with kernel.reset [Translation][Validator] Review Russian translation (114 - 120) Review validator-related persian translation with id 120 [Scheduler] Clarify description of exclusion time ...
2 parents 62d1a43 + 7ced01a commit ee1b504

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed
 

‎IpUtils.php

+10
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,16 @@ public static function anonymize(string $ip/* , int $v4Bytes = 1, int $v6Bytes =
196196
throw new \InvalidArgumentException('Cannot anonymize more than 4 bytes for IPv4 and 16 bytes for IPv6.');
197197
}
198198

199+
/**
200+
* If the IP contains a % symbol, then it is a local-link address with scoping according to RFC 4007
201+
* In that case, we only care about the part before the % symbol, as the following functions, can only work with
202+
* the IP address itself. As the scope can leak information (containing interface name), we do not want to
203+
* include it in our anonymized IP data.
204+
*/
205+
if (str_contains($ip, '%')) {
206+
$ip = substr($ip, 0, strpos($ip, '%'));
207+
}
208+
199209
$wrappedIPv6 = false;
200210
if (str_starts_with($ip, '[') && str_ends_with($ip, ']')) {
201211
$wrappedIPv6 = true;

‎RequestStack.php

+7
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,11 @@ public function getSession(): SessionInterface
114114

115115
throw new SessionNotFoundException();
116116
}
117+
118+
public function resetRequestFormats(): void
119+
{
120+
static $resetRequestFormats;
121+
$resetRequestFormats ??= \Closure::bind(static fn () => self::$formats = null, null, Request::class);
122+
$resetRequestFormats();
123+
}
117124
}

‎Tests/IpUtilsTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ public static function anonymizedIpData()
147147
['[2a01:198::3]', '[2a01:198::]'],
148148
['::ffff:123.234.235.236', '::ffff:123.234.235.0'], // IPv4-mapped IPv6 addresses
149149
['::123.234.235.236', '::123.234.235.0'], // deprecated IPv4-compatible IPv6 address
150+
['fe80::1fc4:15d8:78db:2319%enp4s0', 'fe80::'], // IPv6 link-local with RFC4007 scoping
150151
];
151152
}
152153

‎Tests/RequestStackTest.php

+14
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,18 @@ public function testGetParentRequest()
7474
$requestStack->push($secondSubRequest);
7575
$this->assertSame($firstSubRequest, $requestStack->getParentRequest());
7676
}
77+
78+
public function testResetRequestFormats()
79+
{
80+
$requestStack = new RequestStack();
81+
82+
$request = Request::create('/foo');
83+
$request->setFormat('foo', ['application/foo']);
84+
85+
$this->assertSame(['application/foo'], $request->getMimeTypes('foo'));
86+
87+
$requestStack->resetRequestFormats();
88+
89+
$this->assertSame([], $request->getMimeTypes('foo'));
90+
}
7791
}

0 commit comments

Comments
 (0)
Please sign in to comment.