diff --git a/lib/private/Http/Client/Client.php b/lib/private/Http/Client/Client.php index 03b09bf54b7..3b89af31f93 100644 --- a/lib/private/Http/Client/Client.php +++ b/lib/private/Http/Client/Client.php @@ -112,12 +112,16 @@ class Client implements IClient { * * @return string */ - private function getProxyUri(): string { - $proxyHost = $this->config->getSystemValue('proxy', null); - $proxyUserPwd = $this->config->getSystemValue('proxyuserpwd', null); + private function getProxyUri(): ?string { + $proxyHost = $this->config->getSystemValue('proxy', ''); + if ($proxyHost === '' || $proxyHost === null) { + return null; + } + + $proxyUserPwd = $this->config->getSystemValue('proxyuserpwd', ''); $proxyUri = ''; - if ($proxyUserPwd !== null) { + if ($proxyUserPwd === '' || $proxyUserPwd === null) { $proxyUri .= $proxyUserPwd . '@'; } if ($proxyHost !== null) { diff --git a/tests/lib/Http/Client/ClientTest.php b/tests/lib/Http/Client/ClientTest.php index 7f12a824d17..3dae622a0b8 100644 --- a/tests/lib/Http/Client/ClientTest.php +++ b/tests/lib/Http/Client/ClientTest.php @@ -77,12 +77,22 @@ class ClientTest extends \Test\TestCase { $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')); }