fix: only escape envs after v239+
This commit is contained in:
@@ -1360,45 +1360,40 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
|
|||||||
if ($this->pull_request_id === 0) {
|
if ($this->pull_request_id === 0) {
|
||||||
foreach ($this->application->runtime_environment_variables as $env) {
|
foreach ($this->application->runtime_environment_variables as $env) {
|
||||||
// This is necessary because we have to escape the value of the environment variable
|
// This is necessary because we have to escape the value of the environment variable
|
||||||
// but only if the environment variable is created after the 15th of March 2024
|
// but only if the environment variable is created after 4.0.0-beta.240
|
||||||
// when I implemented the escaping feature.
|
// when I implemented the escaping feature.
|
||||||
|
|
||||||
// Old environment variables are not escaped, because it could break the application
|
// Old environment variables are not escaped, because it could break the application
|
||||||
// as the application could expect the unescaped value.
|
// as the application could expect the unescaped value.
|
||||||
|
if ($env->version === '4.0.0-beta.239') {
|
||||||
// Yes, I worked on March 15th, 2024, and I implemented this feature.
|
|
||||||
// It was a national holiday in Hungary.
|
|
||||||
|
|
||||||
// Welcome to the life of a solopreneur.
|
|
||||||
if ($env->created_at > '2024-03-15T20:42:42.000000Z') {
|
|
||||||
$real_value = escapeEnvVariables($env->real_value);
|
|
||||||
} else {
|
|
||||||
$real_value = $env->value;
|
$real_value = $env->value;
|
||||||
|
} else {
|
||||||
|
$real_value = escapeEnvVariables($env->real_value);
|
||||||
}
|
}
|
||||||
$environment_variables->push("$env->key=$real_value");
|
$environment_variables->push("$env->key=$real_value");
|
||||||
}
|
}
|
||||||
foreach ($this->application->nixpacks_environment_variables as $env) {
|
foreach ($this->application->nixpacks_environment_variables as $env) {
|
||||||
if ($env->created_at > '2024-03-15T20:42:42.000000Z') {
|
if ($env->version === '4.0.0-beta.239') {
|
||||||
$real_value = escapeEnvVariables($env->real_value);
|
|
||||||
} else {
|
|
||||||
$real_value = $env->value;
|
$real_value = $env->value;
|
||||||
|
} else {
|
||||||
|
$real_value = escapeEnvVariables($env->real_value);
|
||||||
}
|
}
|
||||||
$environment_variables->push("$env->key=$real_value");
|
$environment_variables->push("$env->key=$real_value");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
foreach ($this->application->runtime_environment_variables_preview as $env) {
|
foreach ($this->application->runtime_environment_variables_preview as $env) {
|
||||||
if ($env->created_at > '2024-03-15T20:42:42.000000Z') {
|
if ($env->version === '4.0.0-beta.239') {
|
||||||
$real_value = escapeEnvVariables($env->real_value);
|
|
||||||
} else {
|
|
||||||
$real_value = $env->value;
|
$real_value = $env->value;
|
||||||
|
} else {
|
||||||
|
$real_value = escapeEnvVariables($env->real_value);
|
||||||
}
|
}
|
||||||
$environment_variables->push("$env->key=$real_value");
|
$environment_variables->push("$env->key=$real_value");
|
||||||
}
|
}
|
||||||
foreach ($this->application->nixpacks_environment_variables_preview as $env) {
|
foreach ($this->application->nixpacks_environment_variables_preview as $env) {
|
||||||
if ($env->created_at > '2024-03-15T20:42:42.000000Z') {
|
if ($env->version === '4.0.0-beta.239') {
|
||||||
$real_value = escapeEnvVariables($env->real_value);
|
|
||||||
} else {
|
|
||||||
$real_value = $env->value;
|
$real_value = $env->value;
|
||||||
|
} else {
|
||||||
|
$real_value = escapeEnvVariables($env->real_value);
|
||||||
}
|
}
|
||||||
$environment_variables->push("$env->key=$real_value");
|
$environment_variables->push("$env->key=$real_value");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,12 +14,15 @@ class EnvironmentVariable extends Model
|
|||||||
'key' => 'string',
|
'key' => 'string',
|
||||||
'value' => 'encrypted',
|
'value' => 'encrypted',
|
||||||
'is_build_time' => 'boolean',
|
'is_build_time' => 'boolean',
|
||||||
|
'is_multiline' => 'boolean',
|
||||||
|
'is_preview' => 'boolean',
|
||||||
|
'version' => 'string'
|
||||||
];
|
];
|
||||||
protected $appends = ['real_value', 'is_shared'];
|
protected $appends = ['real_value', 'is_shared'];
|
||||||
|
|
||||||
protected static function booted()
|
protected static function booted()
|
||||||
{
|
{
|
||||||
static::created(function ($environment_variable) {
|
static::created(function (EnvironmentVariable $environment_variable) {
|
||||||
if ($environment_variable->application_id && !$environment_variable->is_preview) {
|
if ($environment_variable->application_id && !$environment_variable->is_preview) {
|
||||||
$found = ModelsEnvironmentVariable::where('key', $environment_variable->key)->where('application_id', $environment_variable->application_id)->where('is_preview', true)->first();
|
$found = ModelsEnvironmentVariable::where('key', $environment_variable->key)->where('application_id', $environment_variable->application_id)->where('is_preview', true)->first();
|
||||||
$application = Application::find($environment_variable->application_id);
|
$application = Application::find($environment_variable->application_id);
|
||||||
@@ -31,11 +34,15 @@ class EnvironmentVariable extends Model
|
|||||||
'key' => $environment_variable->key,
|
'key' => $environment_variable->key,
|
||||||
'value' => $environment_variable->value,
|
'value' => $environment_variable->value,
|
||||||
'is_build_time' => $environment_variable->is_build_time,
|
'is_build_time' => $environment_variable->is_build_time,
|
||||||
|
'is_multiline' => $environment_variable->is_multiline,
|
||||||
'application_id' => $environment_variable->application_id,
|
'application_id' => $environment_variable->application_id,
|
||||||
'is_preview' => true,
|
'is_preview' => true
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$environment_variable->update([
|
||||||
|
'version' => config('version')
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
public function service()
|
public function service()
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('environment_variables', function (Blueprint $table) {
|
||||||
|
$table->string('version')->default('4.0.0-beta.239');
|
||||||
|
});
|
||||||
|
Schema::table('shared_environment_variables', function (Blueprint $table) {
|
||||||
|
$table->string('version')->default('4.0.0-beta.239');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('environment_variables', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('version');
|
||||||
|
});
|
||||||
|
Schema::table('shared_environment_variables', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('version');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user