Skip to content

Commit ce952af

Browse files
Merge branch '5.3' into 5.4
* 5.3: expand uninitialized session tests [Lock] Release PostgreSqlStore connection lock on failure [DomCrawler] Fix HTML5 parser charset option cs fix [HttpKernel] Do not attempt to register enum arguments in controller service locator [Mime] Fix missing sprintf in DkimSigner [Translation] [LocoProvider] Use rawurlencode and separate tag setting [Security] fix unserializing session payloads from v4 [Cache] Don't lock when doing nested computations [Messenger] fix Redis support on 32b arch [HttpFoundation] Fix notice when HTTP_PHP_AUTH_USER passed without pass [Security] Add getting started example to README
2 parents 787a0ad + d1314d1 commit ce952af

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

ServerBag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function getHeaders()
8989

9090
// PHP_AUTH_USER/PHP_AUTH_PW
9191
if (isset($headers['PHP_AUTH_USER'])) {
92-
$headers['AUTHORIZATION'] = 'Basic '.base64_encode($headers['PHP_AUTH_USER'].':'.$headers['PHP_AUTH_PW']);
92+
$headers['AUTHORIZATION'] = 'Basic '.base64_encode($headers['PHP_AUTH_USER'].':'.($headers['PHP_AUTH_PW'] ?? ''));
9393
} elseif (isset($headers['PHP_AUTH_DIGEST'])) {
9494
$headers['AUTHORIZATION'] = $headers['PHP_AUTH_DIGEST'];
9595
}

Tests/ServerBagTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ public function testHttpPasswordIsOptional()
5757
], $bag->getHeaders());
5858
}
5959

60+
public function testHttpPasswordIsOptionalWhenPassedWithHttpPrefix()
61+
{
62+
$bag = new ServerBag(['HTTP_PHP_AUTH_USER' => 'foo']);
63+
64+
$this->assertEquals([
65+
'AUTHORIZATION' => 'Basic '.base64_encode('foo:'),
66+
'PHP_AUTH_USER' => 'foo',
67+
], $bag->getHeaders());
68+
}
69+
6070
public function testHttpBasicAuthWithPhpCgi()
6171
{
6272
$bag = new ServerBag(['HTTP_AUTHORIZATION' => 'Basic '.base64_encode('foo:bar')]);

0 commit comments

Comments
 (0)