Skip to content

Commit

Permalink
checking of 'host' part of URL is done in FTP drivers [Closes #146]
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Aug 27, 2021
1 parent 608f441 commit 8400555
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Deployment/CliRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private function createDeployer(array $config): Deployer
if (
empty($config['remote'])
|| !($urlParts = parse_url($config['remote']))
|| !isset($urlParts['scheme'], $urlParts['host'])
|| !isset($urlParts['scheme'])
) {
throw new \Exception("Missing or invalid 'remote' URL in config.");
}
Expand Down
4 changes: 2 additions & 2 deletions src/Deployment/FtpServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ public function __construct(string $url, bool $passiveMode = true)
}
$this->url = $url = parse_url($url);
if (
!isset($url['scheme'], $url['user'], $url['pass'])
!isset($url['scheme'], $url['user'], $url['pass'], $url['host'])
|| ($url['scheme'] !== 'ftp' && $url['scheme'] !== 'ftps')
) {
throw new \InvalidArgumentException('Invalid URL or missing username or password');
throw new \InvalidArgumentException('Invalid URL or missing username, password or host');
} elseif ($url['scheme'] === 'ftps' && !function_exists('ftp_ssl_connect')) {
throw new \Exception('PHP extension OpenSSL is not built statically in PHP.');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Deployment/PhpsecServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct(
string $passPhrase = null
) {
$this->url = parse_url($url);
if (!isset($this->url['scheme'], $this->url['user']) || $this->url['scheme'] !== 'phpsec') {
if (!isset($this->url['scheme'], $this->url['user'], $this->url['host']) || $this->url['scheme'] !== 'phpsec') {
throw new \InvalidArgumentException('Invalid URL or missing username');
}
$this->publicKey = $publicKey;
Expand Down
2 changes: 1 addition & 1 deletion src/Deployment/SshServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function __construct(
throw new \Exception('PHP extension SSH2 is not loaded.');
}
$this->url = parse_url($url);
if (!isset($this->url['scheme'], $this->url['user']) || $this->url['scheme'] !== 'sftp') {
if (!isset($this->url['scheme'], $this->url['user'], $this->url['host']) || $this->url['scheme'] !== 'sftp') {
throw new \InvalidArgumentException('Invalid URL or missing username');
}
$this->publicKey = $publicKey;
Expand Down

0 comments on commit 8400555

Please sign in to comment.