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.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix(application): sanitize service names for HTML form binding and ensure original names are stored in docker compose domains
Andras Bacsai3bb28c29be58
diff --git a/app/Livewire/Project/Application/General.php b/app/Livewire/Project/Application/General.phpindex 74f47232cb..3e89ad6632 100644--- a/app/Livewire/Project/Application/General.php+++ b/app/Livewire/Project/Application/General.php@@ -156,6 +156,14 @@ class General extends Component$this->application->settings->save();}$this->parsedServiceDomains = $this->application->docker_compose_domains ? json_decode($this->application->docker_compose_domains, true) : [];+ // Convert service names with dots to use underscores for HTML form binding+ $sanitizedDomains = [];+ foreach ($this->parsedServiceDomains as $serviceName => $domain) {+ $sanitizedKey = str($serviceName)->slug('_')->toString();+ $sanitizedDomains[$sanitizedKey] = $domain;+ }+ $this->parsedServiceDomains = $sanitizedDomains;+$this->ports_exposes = $this->application->ports_exposes;$this->is_preserve_repository_enabled = $this->application->settings->is_preserve_repository_enabled;$this->is_container_label_escape_enabled = $this->application->settings->is_container_label_escape_enabled;@@ -242,8 +250,26 @@ class General extends Component{$uuid = new Cuid2;$domain = generateFqdn($this->application->destination->server, $uuid);- $this->parsedServiceDomains[$serviceName]['domain'] = $domain;- $this->application->docker_compose_domains = json_encode($this->parsedServiceDomains);+ $sanitizedKey = str($serviceName)->slug('_')->toString();+ $this->parsedServiceDomains[$sanitizedKey]['domain'] = $domain;++ // Convert back to original service names for storage+ $originalDomains = [];+ foreach ($this->parsedServiceDomains as $key => $value) {+ // Find the original service name by checking parsed services+ $originalServiceName = $key;+ if (isset($this->parsedServices['services'])) {+ foreach ($this->parsedServices['services'] as $originalName => $service) {+ if (str($originalName)->slug('_')->toString() === $key) {+ $originalServiceName = $originalName;+ break;+ }+ }+ }+ $originalDomains[$originalServiceName] = $value;+ }++ $this->application->docker_compose_domains = json_encode($originalDomains);$this->application->save();$this->dispatch('success', 'Domain generated.');if ($this->application->build_pack === 'dockercompose') {@@ -429,9 +455,25 @@ class General extends Component$this->application->publish_directory = rtrim($this->application->publish_directory, '/');}if ($this->application->build_pack === 'dockercompose') {- $this->application->docker_compose_domains = json_encode($this->parsedServiceDomains);+ // Convert sanitized service names back to original names for storage+ $originalDomains = [];+ foreach ($this->parsedServiceDomains as $key => $value) {+ // Find the original service name by checking parsed services+ $originalServiceName = $key;+ if (isset($this->parsedServices['services'])) {+ foreach ($this->parsedServices['services'] as $originalName => $service) {+ if (str($originalName)->slug('_')->toString() === $key) {+ $originalServiceName = $originalName;+ break;+ }+ }+ }+ $originalDomains[$originalServiceName] = $value;+ }++ $this->application->docker_compose_domains = json_encode($originalDomains);- foreach ($this->parsedServiceDomains as $serviceName => $service) {+ foreach ($originalDomains as $serviceName => $service) {$domain = data_get($service, 'domain');if ($domain) {if (! validate_dns_entry($domain, $this->application->destination->server)) {diff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.phpindex 39102c39b5..03f26fd04d 100644--- a/resources/views/livewire/project/application/general.blade.php+++ b/resources/views/livewire/project/application/general.blade.php@@ -51,7 +51,7 @@<x-forms.inputhelper="You can specify one domain with path or more with comma. You can specify a port to bind the domain to.<br><br><span class='text-helper'>Example</span><br>- http://app.coolify.io,https://cloud.coolify.io/dashboard<br>- http://app.coolify.io/api/v3<br>- http://app.coolify.io:3000 -> app.coolify.io will point to port 3000 inside the container. "label="Domains for {{ str($serviceName)->headline() }}"- id="parsedServiceDomains.{{ $serviceName }}.domain"></x-forms.input>+ id="parsedServiceDomains.{{ str($serviceName)->slug('_') }}.domain"></x-forms.input><x-forms.button wire:click="generateDomain('{{ $serviceName }}')">GenerateDomain</x-forms.button></div>