We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 12c1c98 + a9e3793 commit a45bb76Copy full SHA for a45bb76
encode_string.go
@@ -219,21 +219,21 @@ var hex = "0123456789abcdef"
219
220
func (e *Encoder) encodeEscapedString(s string) {
221
valLen := len(s)
222
- e.buf = append(e.buf, '"')
223
// write string, the fast path, without utf8 and escape support
224
i := 0
225
for ; i < valLen; i++ {
226
c := s[i]
227
- if c < utf8.RuneSelf && htmlSafeSet[c] {
228
- e.buf = append(e.buf, c)
229
- } else {
+ if c >= utf8.RuneSelf || !htmlSafeSet[c] {
230
break
231
}
232
+ e.buf = append(e.buf, '"')
233
if i == valLen {
+ e.buf = append(e.buf, s...)
234
e.buf = append(e.buf, '"')
235
return
236
+ e.buf = append(e.buf, s[:i]...)
237
e.writeStringSlowPathWithHTMLEscaped(i, s, valLen)
238
239
0 commit comments