Skip to content

HTTPS URLs with user and port are treated as SSH #17

Closed

Description

@dnnsjsk

SshClient::isSshUrl() (

public static function isSshUrl(string $url): bool
{
return str_starts_with($url, 'ssh://')
|| preg_match('/^[^@]+@[^:]+:.+$/', $url) === 1;
) treats any URL that matches ^[^@]+@[^:]+:.+$ as SCP-style SSH. An HTTPS URL with credentials and a port matches that pattern:

SshClient::isSshUrl('https://[email protected]:8443/repo.git'); // true
SshClient::isSshUrl('https://[email protected]/u/r.git');        // false

clone(), fetch(), and push() pick the transport with this check (

pitmaster/src/Pitmaster.php

Lines 264 to 269 in 5beb97d

private static function uploadPackTransport(string $url): UploadPackTransport
{
return SshClient::isSshUrl($url)
? new SshClient()
: new SmartHttpClient();
}
,

pitmaster/src/Repository.php

Lines 4876 to 4892 in 5beb97d

private function uploadPackTransport(string $url): UploadPackTransport
{
$this->assertNetworkOperationAllowed('fetch');
return SshClient::isSshUrl($url)
? new SshClient()
: new SmartHttpClient();
}
private function receivePackTransport(string $url): ReceivePackTransport
{
$this->assertNetworkOperationAllowed('push');
return SshClient::isSshUrl($url)
? new SshClient()
: new SmartHttpClient();
}
), so such an HTTPS remote is sent to the SSH client and fails.

Expected

URLs with a scheme (https://, http://, git://, file://) are never treated as SCP-style SSH. git applies the SCP syntax only when there is no :// before the first colon.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions