From 41765136c2be8158641ad69c7b8c1e96fc3b767d Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Thu, 6 Aug 2020 21:07:56 -0700 Subject: [PATCH] Don't mangle the spaces when editing properties files; closes pterodactyl/panel#2041 (again) --- parser/parser.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/parser/parser.go b/parser/parser.go index a86e194..16276b3 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -3,6 +3,7 @@ package parser import ( "bufio" "encoding/json" + "fmt" "github.com/apex/log" "github.com/beevik/etree" "github.com/buger/jsonparser" @@ -454,7 +455,20 @@ func (f *ConfigurationFile) parsePropertiesFile(path string) error { return err } - _, err = p.Write(w, properties.UTF8) + var s string + // This is a copy of the properties.String() func except we don't plop spaces around + // the key=value configurations since people like to complain about that. + // func (p *Properties) String() string + for _, key := range p.Keys() { + value, _ := p.Get(key) - return err + s = fmt.Sprintf("%s%s=%s\n", s, key, value) + } + + // Can't use the properties.Write() function since that doesn't apply our nicer formatting. + if _, err := w.Write([]byte(s)); err != nil { + return err + } + + return nil }