Try to automatically quote strings.

Incredibly basic checking, only checks if there is a space and no quote
character.

Also includes comments on edited lines to avoid users changing things
that get overwritten again later.
This commit is contained in:
Dane Everitt 2017-04-27 16:26:22 -04:00
parent 30b4934013
commit e4c341795d
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
3 changed files with 11 additions and 2 deletions

View file

@ -147,7 +147,10 @@ class UpdateEmailSettings extends Command
$this->line('Writing new email environment configuration to file.');
foreach ($variables as $key => $value) {
$newValue = $key . '=' . $value;
if (str_contains($value, ' ') && ! str_contains($value, '"')) {
$value = '"' . $value . '"';
}
$newValue = $key . '=' . $value . ' # DO NOT EDIT! set using pterodactyl:mail';
if (preg_match_all('/^' . $key . '=(.*)$/m', $envContents) < 1) {
$envContents = $envContents . "\n" . $newValue;

View file

@ -186,7 +186,10 @@ class UpdateEnvironment extends Command
$bar = $this->output->createProgressBar(count($variables));
foreach ($variables as $key => $value) {
$newValue = $key . '=' . $value;
if (str_contains($value, ' ') && ! str_contains($value, '"')) {
$value = '"' . $value . '"';
}
$newValue = $key . '=' . $value . ' # DO NOT EDIT! set using pterodactyl:env';
if (preg_match_all('/^' . $key . '=(.*)$/m', $envContents) < 1) {
$envContents = $envContents . "\n" . $newValue;