File tree 2 files changed +12
-0
lines changed
src/Symfony/Component/HttpFoundation
2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,7 @@ public function getHeaders()
89
89
90
90
// PHP_AUTH_USER/PHP_AUTH_PW
91
91
if (isset ($ headers ['PHP_AUTH_USER ' ])) {
92
+ $ headers ['PHP_AUTH_PW ' ] = $ headers ['PHP_AUTH_PW ' ] ?? '' ;
92
93
$ headers ['AUTHORIZATION ' ] = 'Basic ' .base64_encode ($ headers ['PHP_AUTH_USER ' ].': ' .$ headers ['PHP_AUTH_PW ' ]);
93
94
} elseif (isset ($ headers ['PHP_AUTH_DIGEST ' ])) {
94
95
$ headers ['AUTHORIZATION ' ] = $ headers ['PHP_AUTH_DIGEST ' ];
Original file line number Diff line number Diff line change @@ -57,6 +57,17 @@ public function testHttpPasswordIsOptional()
57
57
], $ bag ->getHeaders ());
58
58
}
59
59
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
+ 'PHP_AUTH_PW ' => '' ,
68
+ ], $ bag ->getHeaders ());
69
+ }
70
+
60
71
public function testHttpBasicAuthWithPhpCgi ()
61
72
{
62
73
$ bag = new ServerBag (['HTTP_AUTHORIZATION ' => 'Basic ' .base64_encode ('foo:bar ' )]);
You can’t perform that action at this time.
0 commit comments