Skip to content

Commit

Permalink
Avoid double HTML escaping in preformatted JSON values (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
vearutop authored Feb 3, 2021
1 parent a951a0a commit 8008d78
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ctxz/observer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package ctxz

import (
"bytes"
"context"
"encoding/json"

Expand Down Expand Up @@ -53,7 +54,17 @@ func (t tuples) MarshalJSON() ([]byte, error) {
}
}

return json.Marshal(m)
b := bytes.Buffer{}
e := json.NewEncoder(&b)

e.SetEscapeHTML(false)

err := e.Encode(m)
if err != nil {
return nil, err
}

return b.Bytes(), nil
}

// Debug logs debug message.
Expand Down

0 comments on commit 8008d78

Please sign in to comment.