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: multiline variable should be literal + should be multiline in bash with \

Andras Bacsaid1128c7a1e1f
diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php
index 6517aae0ab..35d6aad0af 100644
--- a/app/Jobs/ApplicationDeploymentJob.php
+++ b/app/Jobs/ApplicationDeploymentJob.php
@@ -763,7 +763,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
if ($env->version === '4.0.0-beta.239') {
$real_value = $env->real_value;
} else {
- if ($env->is_literal) {
+ if ($env->is_literal || $env->is_multiline) {
$real_value = '\'' . $real_value . '\'';
} else {
$real_value = escapeEnvVariables($env->real_value);
@@ -804,10 +804,11 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
if ($env->version === '4.0.0-beta.239') {
$real_value = $env->real_value;
} else {
- if ($env->is_literal) {
+ if ($env->is_literal || $env->is_multiline) {
$real_value = '\'' . $real_value . '\'';
} else {
$real_value = escapeEnvVariables($env->real_value);
+ ray($real_value);
}
}
$envs->push($env->key . '=' . $real_value);
@@ -1948,11 +1949,17 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
if ($this->pull_request_id === 0) {
foreach ($this->application->build_environment_variables as $env) {
$value = escapeshellarg($env->real_value);
+ if (str($value)->contains("\n") && data_get($env, 'is_multiline') === true) {
+ $value = str_replace("\n", "\\\n", $value);
+ }
$this->build_args->push("--build-arg {$env->key}={$value}");
}
} else {
foreach ($this->application->build_environment_variables_preview as $env) {
$value = escapeshellarg($env->real_value);
+ if (str($value)->contains("\n") && data_get($env, 'is_multiline') === true) {
+ $value = str_replace("\n", "\\\n", $value);
+ }
$this->build_args->push("--build-arg {$env->key}={$value}");
}
}
@@ -1968,10 +1975,20 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
$dockerfile = collect(Str::of($this->saved_outputs->get('dockerfile'))->trim()->explode("\n"));
if ($this->pull_request_id === 0) {
foreach ($this->application->build_environment_variables as $env) {
- $dockerfile->splice(1, 0, "ARG {$env->key}={$env->real_value}");
+ if (str($env->real_value)->contains("\n") && data_get($env, 'is_multiline') === true) {
+ $value = str_replace("\n", "\\\n", $env->real_value);
+ } else {
+ $value = $env->real_value;
+ }
+ $dockerfile->splice(1, 0, "ARG {$env->key}={$value}");
}
} else {
foreach ($this->application->build_environment_variables_preview as $env) {
+ if (str($env->real_value)->contains("\n") && data_get($env, 'is_multiline') === true) {
+ $value = str_replace("\n", "\\\n", $env->real_value);
+ } else {
+ $value = $env->real_value;
+ }
$dockerfile->splice(1, 0, "ARG {$env->key}={$env->real_value}");
}
}
diff --git a/resources/views/livewire/project/shared/environment-variable/show.blade.php b/resources/views/livewire/project/shared/environment-variable/show.blade.php
index e07766fcbd..b231485476 100644
--- a/resources/views/livewire/project/shared/environment-variable/show.blade.php
+++ b/resources/views/livewire/project/shared/environment-variable/show.blade.php
@@ -63,9 +63,11 @@
@else
<x-forms.checkbox instantSave id="env.is_build_time" label="Build Variable?" />
<x-forms.checkbox instantSave id="env.is_multiline" label="Is Multiline?" />
- <x-forms.checkbox instantSave id="env.is_literal"
- helper="This means that when you use $VARIABLES in a value, it should be interpreted as the actual characters '$VARIABLES' and not as the value of a variable named VARIABLE.<br><br>Useful if you have $ sign in your value and there are some characters after it, but you would not like to interpolate it form another value. In this case, you should set this to true."
- label="Is Literal?" />
+ @if (!data_get($env, 'is_multiline'))
+ <x-forms.checkbox instantSave id="env.is_literal"
+ helper="This means that when you use $VARIABLES in a value, it should be interpreted as the actual characters '$VARIABLES' and not as the value of a variable named VARIABLE.<br><br>Useful if you have $ sign in your value and there are some characters after it, but you would not like to interpolate it form another value. In this case, you should set this to true."
+ label="Is Literal?" />
+ @endif
@endif
@endif
@endif