mirror of
https://github.com/coollabsio/coolify.git
synced 2026-03-11 08:55:47 +00:00
Merge 9c680e3b4b into 201998638a
This commit is contained in:
commit
c78dcf2c01
1 changed files with 28 additions and 0 deletions
|
|
@ -3492,6 +3492,34 @@ NGINX;
|
||||||
function convertGitUrl(string $gitRepository, string $deploymentType, ?GithubApp $source = null): array
|
function convertGitUrl(string $gitRepository, string $deploymentType, ?GithubApp $source = null): array
|
||||||
{
|
{
|
||||||
$repository = $gitRepository;
|
$repository = $gitRepository;
|
||||||
|
|
||||||
|
// URL encode basic auth credentials in HTTP(S) URLs to handle special characters like @ in usernames
|
||||||
|
if (preg_match('/^https?:\/\//', $gitRepository)) {
|
||||||
|
$parsedUrl = parse_url($gitRepository);
|
||||||
|
if ($parsedUrl !== false && (isset($parsedUrl['user']) || isset($parsedUrl['pass']))) {
|
||||||
|
$host = $parsedUrl['host'] ?? '';
|
||||||
|
if ($host !== '') {
|
||||||
|
$scheme = $parsedUrl['scheme'] ?? 'https';
|
||||||
|
$port = isset($parsedUrl['port']) ? ':'.$parsedUrl['port'] : '';
|
||||||
|
$path = $parsedUrl['path'] ?? '';
|
||||||
|
$query = isset($parsedUrl['query']) ? '?'.$parsedUrl['query'] : '';
|
||||||
|
$fragment = isset($parsedUrl['fragment']) ? '#'.$parsedUrl['fragment'] : '';
|
||||||
|
|
||||||
|
// Re-wrap IPv6 hosts with brackets (parse_url strips them)
|
||||||
|
$isIpv6 = str_contains($host, ':');
|
||||||
|
$hostFormatted = $isIpv6 ? '['.$host.']' : $host;
|
||||||
|
|
||||||
|
$user = isset($parsedUrl['user']) ? rawurlencode(rawurldecode($parsedUrl['user'])) : '';
|
||||||
|
$pass = isset($parsedUrl['pass']) ? ':'.rawurlencode(rawurldecode($parsedUrl['pass'])) : '';
|
||||||
|
$hasAuth = ($user !== '' || $pass !== '');
|
||||||
|
$auth = $hasAuth ? $user.$pass.'@' : '';
|
||||||
|
|
||||||
|
$repository = $scheme.'://'.$auth.$hostFormatted.$port.$path.$query.$fragment;
|
||||||
|
$gitRepository = $repository;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$providerInfo = [
|
$providerInfo = [
|
||||||
'host' => null,
|
'host' => null,
|
||||||
'user' => 'git',
|
'user' => 'git',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue