Skip to content

Commit

Permalink
Clean up escape mess
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeuw committed Mar 5, 2019
1 parent cd399dc commit 805e587
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions gqserver/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ type State struct {
// semi-colon separated value.
func ssvToJson(ssv string) (ret []byte) {
unescape := func(s string) string {
r := strings.Replace(s, "\\\\", "\\", -1)
r = strings.Replace(r, "\\=", "=", -1)
r = strings.Replace(r, "\\;", ";", -1)
r := strings.Replace(s, `\\`, `\`, -1)
r = strings.Replace(r, `\=`, `=`, -1)
r = strings.Replace(r, `\;`, `;`, -1)
return r
}
lines := strings.Split(unescape(ssv), ";")
Expand All @@ -46,7 +46,7 @@ func ssvToJson(ssv string) (ret []byte) {
sp := strings.SplitN(ln, "=", 2)
key := sp[0]
value := sp[1]
ret = append(ret, []byte("\""+key+"\":\""+value+"\",")...)
ret = append(ret, []byte(`"`+key+`":"`+value+`",`)...)

}
ret = ret[:len(ret)-1] // remove the last comma
Expand Down

0 comments on commit 805e587

Please sign in to comment.