8000 Merge branch '4.4' into 5.3 · symfony/symfony@e39ee06 · GitHub
[go: up one dir, main page]

Skip to content

Commit e39ee06

Browse files
committed
Merge branch '4.4' into 5.3
* 4.4: [Security] Fix str_contains type mismatch in ChannelListener remove 5.2 branch from PR template
2 parents c522cc9 + af897a1 commit e39ee06

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
| Q | A
22
| ------------- | ---
3-
| Branch? | 5.4 for features / 4.4, 5.2 or 5.3 for bug fixes <!-- see below -->
3+
| Branch? | 5.4 for features / 4.4 or 5.3 for bug fixes <!-- see below -->
44
| Bug fix? | yes/no
55
| New feature? | yes/no <!-- please update src/**/CHANGELOG.md files -->
66
| Deprecations? | yes/no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function supports(Request $request): ?bool
4949
if (null !== $this->logger) {
5050
if ('https' === $request->headers->get('X-Forwarded-Proto')) {
5151
$this->logger->info('Redirecting to HTTPS. ("X-Forwarded-Proto" header is set to "https" - did you set "trusted_proxies" correctly?)');
52-
} elseif (str_contains($request->headers->get('Forwarded'), 'proto=https')) {
52+
} elseif (str_contains($request->headers->get('Forwarded', ''), 'proto=https')) {
5353
$this->logger->info('Redirecting to HTTPS. ("Forwarded" header is set to "proto=https" - did you set "trusted_proxies" correctly?)');
5454
} else {
5555
$this->logger->info('Redirecting to HTTPS.');

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
namespace Symfony\Component\Security\Http\Tests\Firewall;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Psr\Log\NullLogger;
16+
use Symfony\Component\HttpFoundation\HeaderBag;
1517
use Symfony\Component\HttpFoundation\Request;
1618
use Symfony\Component\HttpFoundation\Response;
1719
use Symfony\Component\HttpKernel\Event\RequestEvent;
@@ -153,4 +155,29 @@ public function testHandleWithSecuredRequestAndHttpChannel()
153155

154156
$this->assertSame($response, $event->getResponse());
155157
}
158+
159+
public function testSupportsWithoutHeaders()
160+
{
161+
$request = $this->createMock(Request::class);
162+
$request
163+
->expects($this->any())
164+
->method('isSecure')
165+
->willReturn(false)
166+
;
167+
$request->headers = new HeaderBag();
168+
169+
$accessMap = $this->createMock(AccessMapInterface::class);
170+
$accessMap
171+
->expects($this->any())
172+
->method('getPatterns')
173+
->with($this->equalTo($request))
174+
->willReturn([[], 'https'])
175+
;
176+
177+
$entryPoint = $this->createMock(AuthenticationEntryPointInterface::class);
178+
179+
$listener = new ChannelListener($accessMap, $entryPoint, new NullLogger());
180+
181+
$this->assertTrue($listener->supports($request));
182+
}
156183
}

0 commit comments

Comments
 (0)
0