Merge pull request #16721 from nextcloud/fix/16644

Correctly handle emtpy string in proxyuserpwd config
This commit is contained in:
Roeland Jago Douma 2019-08-11 22:46:01 +02:00 committed by GitHub
commit f465f9d4b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 6 deletions

View File

@ -95,15 +95,15 @@ class Client implements IClient {
* @return string|null * @return string|null
*/ */
private function getProxyUri(): ?string { private function getProxyUri(): ?string {
$proxyHost = $this->config->getSystemValue('proxy', null); $proxyHost = $this->config->getSystemValue('proxy', '');
if ($proxyHost === null) { if ($proxyHost === '' || $proxyHost === null) {
return null; return null;
} }
$proxyUserPwd = $this->config->getSystemValue('proxyuserpwd', null); $proxyUserPwd = $this->config->getSystemValue('proxyuserpwd', '');
if ($proxyUserPwd === null) { if ($proxyUserPwd === '' || $proxyUserPwd === null) {
return $proxyHost; return $proxyHost;
} }

View File

@ -70,12 +70,22 @@ class ClientTest extends \Test\TestCase {
$this->config $this->config
->expects($this->at(0)) ->expects($this->at(0))
->method('getSystemValue') ->method('getSystemValue')
->with('proxy', null) ->with(
$this->equalTo('proxy'),
$this->callback(function ($input) {
return $input === '';
})
)
->willReturn('foo'); ->willReturn('foo');
$this->config $this->config
->expects($this->at(1)) ->expects($this->at(1))
->method('getSystemValue') ->method('getSystemValue')
->with('proxyuserpwd', null) ->with(
$this->equalTo('proxyuserpwd'),
$this->callback(function ($input) {
return $input === '';
})
)
->willReturn('username:password'); ->willReturn('username:password');
$this->assertSame('username:password@foo', self::invokePrivate($this->client, 'getProxyUri')); $this->assertSame('username:password@foo', self::invokePrivate($this->client, 'getProxyUri'));
} }