mirror of
https://github.com/golang/go.git
synced 2025-11-09 13:11:03 +00:00
encoding/json: drop MarshalForHTML; gofix calls to Marshal.
I've elected to omit escaping the output of Marshalers for now. I haven't thought through the implications of that; I suspect that double escaping might be the undoing of that idea. Fixes #3127. R=golang-dev, r CC=golang-dev https://golang.org/cl/5694098
This commit is contained in:
parent
740d503866
commit
9dd746c4cb
4 changed files with 10 additions and 21 deletions
|
|
@ -123,17 +123,6 @@ func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error) {
|
|||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
// MarshalForHTML is like Marshal but applies HTMLEscape to the output.
|
||||
func MarshalForHTML(v interface{}) ([]byte, error) {
|
||||
b, err := Marshal(v)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
HTMLEscape(&buf, b)
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
// HTMLEscape appends to dst the JSON-encoded src with <, >, and &
|
||||
// characters inside string literals changed to \u003c, \u003e, \u0026
|
||||
// so that the JSON will be safe to embed inside HTML <script> tags.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue