Skip to content

Commit f487600

Browse files
Merge branch '7.4' into 8.0
* 7.4: [SecurityBundle] Fix tests on Windows use the empty string instead of null as an array offset pass the empty string instead of null as key to array_key_exists() fix test setup [Validator] Review Turkish translations [Validator] Review Croatian translations [Console] Add #[Input] attribute to support DTOs in commands [Security][SecurityBundle] Dump role hierarchy as mermaid chart [DependencyInjection] Allow `Class::function(...)` and `global_function(...)` closures in PHP DSL for factories [VarExporter] Add support for exporting named closures [Validator] Review translations for Polish (pl) use the empty string instead of null as an array offset Review translations for Chinese (zh_TW) [Serializer] Adjust ObjectNormalizerTest for the accessor method changes from #61097 fix merge [Security] Fix `HttpUtils::createRequest()` when the base request is forwarded map legacy options to the "sentinel" key when parsing DSNs fix setup to actually run Redis Sentinel/Cluster integration tests [Routing] Don't rebuild cache when controller action body changes
2 parents 807aba0 + 1bc99e9 commit f487600

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

HttpUtils.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,13 @@ public function createRedirectResponse(Request $request, string $path, int $stat
6565
*/
6666
public function createRequest(Request $request, string $path): Request
6767
{
68+
if ($trustedProxies = Request::getTrustedProxies()) {
69+
Request::setTrustedProxies([], Request::getTrustedHeaderSet());
70+
}
6871
$newRequest = Request::create($this->generateUri($request, $path), 'get', [], $request->cookies->all(), [], $request->server->all());
72+
if ($trustedProxies) {
73+
Request::setTrustedProxies($trustedProxies, Request::getTrustedHeaderSet());
74+
}
6975

7076
static $setSession;
7177

Logout/LogoutUrlGenerator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ private function getListener(?string $key): array
138138
}
139139

140140
// Fetch from injected current firewall information, if possible
141-
if (isset($this->listeners[$this->currentFirewallName])) {
142-
return $this->listeners[$this->currentFirewallName];
141+
if (isset($this->listeners[$this->currentFirewallName ?? ''])) {
142+
return $this->listeners[$this->currentFirewallName ?? ''];
143143
}
144144

145145
foreach ($this->listeners as $listener) {

Tests/HttpUtilsTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,16 @@ public static function provideSecurityRequestAttributes()
228228
];
229229
}
230230

231+
public function testCreateRequestHandlesTrustedHeaders()
232+
{
233+
Request::setTrustedProxies(['127.0.0.1'], Request::HEADER_X_FORWARDED_PREFIX);
234+
235+
$this->assertSame(
236+
'http://localhost/foo/',
237+
(new HttpUtils())->createRequest(Request::create('/', server: ['HTTP_X_FORWARDED_PREFIX' => '/foo']), '/')->getUri(),
238+
);
239+
}
240+
231241
public function testCheckRequestPath()
232242
{
233243
$utils = new HttpUtils($this->getUrlGenerator());

0 commit comments

Comments
 (0)