From: Joe Tsai Date: Mon, 20 Feb 2023 08:42:27 +0000 (-0800) Subject: encoding/json: use append for HTMLEscape X-Git-Tag: go1.21rc1~1463 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=2de406bb9e26df19a31b5f6111bb221b60964d48;p=gostls13.git encoding/json: use append for HTMLEscape Use append for HTMLEscape similar to Indent and Compact. Move it to indent.go alongside Compact, as it shares similar logic. In a future CL, we will modify appendCompact to be written in terms of appendHTMLEscape, but we need to first move the JSON decoder logic out of the main loop of appendCompact. Change-Id: I131c64cd53d5d2b4ca798b37349aeefe17b418c7 Reviewed-on: https://go-review.googlesource.com/c/go/+/471198 TryBot-Result: Gopher Robot Reviewed-by: Dmitri Shuralyov Run-TryBot: Joseph Tsai Reviewed-by: Daniel Martí Reviewed-by: Than McIntosh Reviewed-by: Johan Brandhorst-Satzkorn Auto-Submit: Joseph Tsai --- diff --git a/src/encoding/json/encode.go b/src/encoding/json/encode.go index ff0e40d532..de639aa008 100644 --- a/src/encoding/json/encode.go +++ b/src/encoding/json/encode.go @@ -183,41 +183,6 @@ func MarshalIndent(v any, prefix, indent string) ([]byte, error) { return b2, nil } -// HTMLEscape appends to dst the JSON-encoded src with <, >, &, U+2028 and U+2029 -// characters inside string literals changed to \u003c, \u003e, \u0026, \u2028, \u2029 -// so that the JSON will be safe to embed inside HTML