Skip to content

Commit b8fe549

Browse files
authored
escape html encoding to marshal json output completely (#1226)
1 parent e2123e2 commit b8fe549

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

internal/pkg/print/print.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package print
22

33
import (
44
"bufio"
5+
"bytes"
56
"encoding/json"
67
"errors"
78
"fmt"
@@ -256,10 +257,15 @@ func (p *Printer) DebugInputModel(model any) {
256257
func (p *Printer) OutputResult(outputFormat string, output any, prettyOutputFunc func() error) error {
257258
switch outputFormat {
258259
case JSONOutputFormat:
259-
details, err := json.MarshalIndent(output, "", " ")
260+
buffer := &bytes.Buffer{}
261+
encoder := json.NewEncoder(buffer)
262+
encoder.SetEscapeHTML(false)
263+
encoder.SetIndent("", " ")
264+
err := encoder.Encode(output)
260265
if err != nil {
261266
return fmt.Errorf("marshal json: %w", err)
262267
}
268+
details := buffer.Bytes()
263269
p.Outputln(string(details))
264270

265271
return nil

0 commit comments

Comments
 (0)