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

@ -12,6 +12,9 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
* Added ability to reinstall a server using the currently assigned service and option.
* Added ability to change a server's service and service option, as well as change pack assignments and other management services in that regard.
### Changed
* Environment setting commands now attempt to auto-quote strings with spaces in them, as well as comment lines that are edited to avoid manual changes being overwritten.
## v0.6.0-beta.2.1 (Courageous Carniadactylus)
### Fixed
* `[beta.2]` — Suspended servers now show as suspended.

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;