mirror of
https://github.com/tiennm99/coolify.git
synced 2026-04-17 17:21:04 +00:00
fix(env): skip escaping for valid JSON in environment variables (#6160)
Prevent double-escaping of COMPOSER_AUTH and other JSON environment variables by detecting valid JSON objects/arrays in realValue() and skipping quote escaping entirely. This fixes broken JSON values passed to runtime services while maintaining proper escaping for non-JSON values. - Add JSON detection before escaping logic in EnvironmentVariable::realValue() - JSON objects/arrays pass through unmodified, avoiding quote corruption - Add comprehensive test coverage for JSON vs non-JSON escaping behavior
This commit is contained in:
@@ -123,6 +123,12 @@ class EnvironmentVariable extends BaseModel
|
||||
}
|
||||
|
||||
$real_value = $this->get_real_environment_variables($this->value, $resource);
|
||||
|
||||
// Skip escaping for valid JSON objects/arrays to prevent quote corruption (see #6160)
|
||||
if (json_validate($real_value) && (str_starts_with($real_value, '{') || str_starts_with($real_value, '['))) {
|
||||
return $real_value;
|
||||
}
|
||||
|
||||
if ($this->is_literal || $this->is_multiline) {
|
||||
$real_value = '\''.$real_value.'\'';
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user