Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix(application): do not crash on commit links for git:// repositories

Andras Bacsai0a144a5d7a6e
diff --git a/app/Models/Application.php b/app/Models/Application.php
index 9db9d6d58d..d5da496ffb 100644
--- a/app/Models/Application.php
+++ b/app/Models/Application.php
@@ -743,7 +743,7 @@ class Application extends BaseModel
$git_repository = 'https://'.parse_url($git_repository, PHP_URL_HOST).parse_url($git_repository, PHP_URL_PATH);
}
- if (! filter_var($git_repository, FILTER_VALIDATE_URL)) {
+ if (! filter_var($git_repository, FILTER_VALIDATE_URL) || ! in_array(parse_url($git_repository, PHP_URL_SCHEME), ['http', 'https'], true)) {
return null;
}
diff --git a/tests/Unit/ApplicationGitCommitLinkTest.php b/tests/Unit/ApplicationGitCommitLinkTest.php
index 6ebbaf8eea..7d9bb2b8ca 100644
--- a/tests/Unit/ApplicationGitCommitLinkTest.php
+++ b/tests/Unit/ApplicationGitCommitLinkTest.php
@@ -44,6 +44,7 @@ it('does not generate commit links from incomplete repository URLs', function (s
})->with([
'missing host' => 'https://',
'missing scheme' => 'github.com/coollabsio/coolify',
+ 'git protocol' => 'git://git.example.com/coollabsio/coolify.git',
]);
it('converts scp-style remotes with generic usernames into https repository links', function (string $repository, string $expectedBranch, string $expectedCommits, string $expectedWebhook) {