MCPcopy
hub / github.com/uber-go/zap / safeAddString

Method safeAddString

zapcore/json_encoder.go:488–495  ·  view source on GitHub ↗

safeAddString JSON-escapes a string and appends it to the internal buffer. Unlike the standard library's encoder, it doesn't attempt to protect the user from browser vulnerabilities or JSONP-related problems.

(s string)

Source from the content-addressed store, hash-verified

486// Unlike the standard library's encoder, it doesn't attempt to protect the
487// user from browser vulnerabilities or JSONP-related problems.
488func (enc *jsonEncoder) safeAddString(s string) {
489 safeAppendStringLike(
490 (*buffer.Buffer).AppendString,
491 utf8.DecodeRuneInString,
492 enc.buf,
493 s,
494 )
495}
496
497// safeAddByteString is no-alloc equivalent of safeAddString(string(s)) for s []byte.
498func (enc *jsonEncoder) safeAddByteString(s []byte) {

Callers 3

AppendStringMethod · 0.95
addKeyMethod · 0.95
TestJSONEscapingFunction · 0.95

Calls 1

safeAppendStringLikeFunction · 0.85

Tested by 1

TestJSONEscapingFunction · 0.76