Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Correctly handle emtpy string in proxyuserpwd config
As documented, the default value for config value proxyuserpwd is ''.
However, that value results in the error:
 "cURL error 5: Unsupported proxy syntax in '@'".
This patch handles the values of '' and null (the default in the code)
the same for config values proxyuserpwd and proxy.

Signed-off-by: Scott Shambarger <[email protected]>
  • Loading branch information
sshambar authored and rullzer committed Aug 11, 2019
commit edf946dfc7c8ddc5f4ad125d2a0c780bbc63e769
8 changes: 4 additions & 4 deletions lib/private/Http/Client/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ private function getCertBundle(): string {
* @return string|null
*/
private function getProxyUri(): ?string {
$proxyHost = $this->config->getSystemValue('proxy', null);
$proxyHost = $this->config->getSystemValue('proxy', '');

if ($proxyHost === null) {
if ($proxyHost === '' || $proxyHost === null) {
return null;
}

$proxyUserPwd = $this->config->getSystemValue('proxyuserpwd', null);
$proxyUserPwd = $this->config->getSystemValue('proxyuserpwd', '');

if ($proxyUserPwd === null) {
if ($proxyUserPwd === '' || $proxyUserPwd === null) {
return $proxyHost;
}

Expand Down
14 changes: 12 additions & 2 deletions tests/lib/Http/Client/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,22 @@ public function testGetProxyUriProxyHostWithPassword(): void {
$this->config
->expects($this->at(0))
->method('getSystemValue')
->with('proxy', null)
->with(
$this->equalTo('proxy'),
$this->callback(function ($input) {
return $input === '';
})
)
->willReturn('foo');
$this->config
->expects($this->at(1))
->method('getSystemValue')
->with('proxyuserpwd', null)
->with(
$this->equalTo('proxyuserpwd'),
$this->callback(function ($input) {
return $input === '';
})
)
->willReturn('username:password');
$this->assertSame('username:password@foo', self::invokePrivate($this->client, 'getProxyUri'));
}
Expand Down