aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/json/encode.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/encoding/json/encode.go')
-rw-r--r--src/encoding/json/encode.go6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/encoding/json/encode.go b/src/encoding/json/encode.go
index 6bb6de8f07..6ef4e45c1e 100644
--- a/src/encoding/json/encode.go
+++ b/src/encoding/json/encode.go
@@ -850,8 +850,7 @@ func (e *encodeState) string(s string, escapeHTML bool) int {
start := 0
for i := 0; i < len(s); {
if b := s[i]; b < utf8.RuneSelf {
- if 0x20 <= b && b != '\\' && b != '"' &&
- (!escapeHTML || b != '<' && b != '>' && b != '&') {
+ if htmlSafeSet[b] || (!escapeHTML && safeSet[b]) {
i++
continue
}
@@ -928,8 +927,7 @@ func (e *encodeState) stringBytes(s []byte, escapeHTML bool) int {
start := 0
for i := 0; i < len(s); {
if b := s[i]; b < utf8.RuneSelf {
- if 0x20 <= b && b != '\\' && b != '"' &&
- (!escapeHTML || b != '<' && b != '>' && b != '&') {
+ if htmlSafeSet[b] || (!escapeHTML && safeSet[b]) {
i++
continue
}