Skip to content

Commit e4c3417

Browse files
committed
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.
1 parent 30b4934 commit e4c3417

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
1212
* Added ability to reinstall a server using the currently assigned service and option.
1313
* Added ability to change a server's service and service option, as well as change pack assignments and other management services in that regard.
1414

15+
### Changed
16+
* 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.
17+
1518
## v0.6.0-beta.2.1 (Courageous Carniadactylus)
1619
### Fixed
1720
* `[beta.2]` — Suspended servers now show as suspended.

app/Console/Commands/UpdateEmailSettings.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,10 @@ public function handle()
147147

148148
$this->line('Writing new email environment configuration to file.');
149149
foreach ($variables as $key => $value) {
150-
$newValue = $key . '=' . $value;
150+
if (str_contains($value, ' ') && ! str_contains($value, '"')) {
151+
$value = '"' . $value . '"';
152+
}
153+
$newValue = $key . '=' . $value . ' # DO NOT EDIT! set using pterodactyl:mail';
151154

152155
if (preg_match_all('/^' . $key . '=(.*)$/m', $envContents) < 1) {
153156
$envContents = $envContents . "\n" . $newValue;

app/Console/Commands/UpdateEnvironment.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,10 @@ public function handle()
186186
$bar = $this->output->createProgressBar(count($variables));
187187

188188
foreach ($variables as $key => $value) {
189-
$newValue = $key . '=' . $value;
189+
if (str_contains($value, ' ') && ! str_contains($value, '"')) {
190+
$value = '"' . $value . '"';
191+
}
192+
$newValue = $key . '=' . $value . ' # DO NOT EDIT! set using pterodactyl:env';
190193

191194
if (preg_match_all('/^' . $key . '=(.*)$/m', $envContents) < 1) {
192195
$envContents = $envContents . "\n" . $newValue;

0 commit comments

Comments
 (0)