Detect invalid ssh URLs, fixes #1124
parent
8af6581bdf
commit
04c6670f0c
|
@ -265,6 +265,10 @@ class GitDownloader extends VcsDownloader
|
||||||
{
|
{
|
||||||
$handler = array($this, 'outputHandler');
|
$handler = array($this, 'outputHandler');
|
||||||
|
|
||||||
|
if (preg_match('{^ssh://[^@]+@[^:]+:[^0-9]+}', $url)) {
|
||||||
|
throw new \InvalidArgumentException('The source URL '.$url.' is invalid, ssh URLs should have a port number after ":".'."\n".'Use ssh://git@example.com:22/path or just git@example.com:path if you do not want to provide a password or custom port.');
|
||||||
|
}
|
||||||
|
|
||||||
// public github, autoswitch protocols
|
// public github, autoswitch protocols
|
||||||
if (preg_match('{^(?:https?|git)(://github.com/.*)}', $url, $match)) {
|
if (preg_match('{^(?:https?|git)(://github.com/.*)}', $url, $match)) {
|
||||||
$protocols = $this->config->get('github-protocols');
|
$protocols = $this->config->get('github-protocols');
|
||||||
|
|
|
@ -45,6 +45,10 @@ class GitDriver extends VcsDriver
|
||||||
throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.dirname($this->repoDir).'" directory is not writable by the current user.');
|
throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.dirname($this->repoDir).'" directory is not writable by the current user.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (preg_match('{^ssh://[^@]+@[^:]+:[^0-9]+}', $this->url)) {
|
||||||
|
throw new \InvalidArgumentException('The source URL '.$this->url.' is invalid, ssh URLs should have a port number after ":".'."\n".'Use ssh://git@example.com:22/path or just git@example.com:path if you do not want to provide a password or custom port.');
|
||||||
|
}
|
||||||
|
|
||||||
// update the repo if it is a valid git repository
|
// update the repo if it is a valid git repository
|
||||||
if (is_dir($this->repoDir) && 0 === $this->process->execute('git remote', $output, $this->repoDir)) {
|
if (is_dir($this->repoDir) && 0 === $this->process->execute('git remote', $output, $this->repoDir)) {
|
||||||
if (0 !== $this->process->execute('git remote update --prune origin', $output, $this->repoDir)) {
|
if (0 !== $this->process->execute('git remote update --prune origin', $output, $this->repoDir)) {
|
||||||
|
|
Loading…
Reference in New Issue