Skip to content

Commit 9f34f69

Browse files
committed
Merge branch '7.3' into 7.4
* 7.3: [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 5cef36b + f514d32 commit 9f34f69

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
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

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)