Skip to content

Commit

Permalink
Merge pull request #68 from user202729/config_no_escape_html_2
Browse files Browse the repository at this point in the history
Do not escape HTML in config file
  • Loading branch information
xalanq committed Mar 1, 2020
2 parents 56ad151 + 6ca764e commit 4aff868
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions config/config.go
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"io/ioutil"
"os"
"bytes"
"path/filepath"

"github.com/fatih/color"
Expand Down Expand Up @@ -79,10 +80,14 @@ func (c *Config) load() (err error) {

// save file to path
func (c *Config) save() (err error) {
data, err := json.MarshalIndent(c, "", " ")
var data bytes.Buffer
encoder := json.NewEncoder(&data)
encoder.SetIndent("", " ")
encoder.SetEscapeHTML(false)
err = encoder.Encode(c)
if err == nil {
os.MkdirAll(filepath.Dir(c.path), os.ModePerm)
err = ioutil.WriteFile(c.path, data, 0644)
err = ioutil.WriteFile(c.path, data.Bytes(), 0644)
}
if err != nil {
color.Red("Cannot save config to %v\n%v", c.path, err.Error())
Expand Down

0 comments on commit 4aff868

Please sign in to comment.