Skip to content

Commit 1b5fe8d

Browse files
feat(client): support optional json html escaping
1 parent aa5fbb8 commit 1b5fe8d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

internal/requestconfig/requestconfig.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,13 @@ func NewRequestConfig(ctx context.Context, method string, u string, body interfa
133133
// Fallback to json serialization if none of the serialization functions that we expect
134134
// to see is present.
135135
if body != nil && !hasSerializationFunc {
136-
content, err := json.Marshal(body)
137-
if err != nil {
136+
buf := new(bytes.Buffer)
137+
enc := json.NewEncoder(buf)
138+
enc.SetEscapeHTML(true)
139+
if err := enc.Encode(body); err != nil {
138140
return nil, err
139141
}
140-
reader = bytes.NewBuffer(content)
142+
reader = buf
141143
}
142144

143145
req, err := http.NewRequestWithContext(ctx, method, u, nil)

0 commit comments

Comments
 (0)