Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
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 blizzz committed Oct 11, 2019
commit 3fc86e639efcc01b63f1be903c405ea264638d56
12 changes: 8 additions & 4 deletions lib/private/Http/Client/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,16 @@ private function getCertBundle() {
*
* @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 = '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dead code


if ($proxyUserPwd !== null) {
if ($proxyUserPwd === '' || $proxyUserPwd === null) {
$proxyUri .= $proxyUserPwd . '@';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$proxyUri .= $proxyUserPwd . '@';
return $proxyHost;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets keep the backport as identical as we can to the original. Then we can do what you suggest in a PR against master ;)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you suggest in a PR against master ;)

I already did ;) #14363

You cannot backport #16721 because it needs #14363 to be backported.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#14363 is not totally needed, to fix the issue that proxy is set to '@' when the documented default values are used in config.php instead of null.

}
if ($proxyHost !== null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dead code

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 @@ -77,12 +77,22 @@ public function testGetProxyUriProxyHostWithPassword() {
$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