aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/encoding
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2013-08-09 18:33:57 -0400
committerRuss Cox <rsc@golang.org>2013-08-09 18:33:57 -0400
commit080e00d55d37be67be30e2723233594e64097edf (patch)
tree5352fd9e86da09b41220317b99f1ee0f0f142de2 /src/pkg/encoding
parent36f223dace5dcdb7afc381c51e0484ff473e2e88 (diff)
downloadgo-080e00d55d37be67be30e2723233594e64097edf.tar.xz
encoding/json: escape & always
There are a few different places in the code that escape possibly-problematic characters like < > and &. This one was the only one missing &, so add it. This means that if you Marshal a string, you get the same answer you do if you Marshal a string and pass it through the compactor. (Ironically, the compaction makes the string longer.) Because html/template invokes json.Marshal to prepare escaped strings for JavaScript, this changes the form of some of the escaped strings, but not their meaning. R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/12708044
Diffstat (limited to 'src/pkg/encoding')
-rw-r--r--src/pkg/encoding/json/encode.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/pkg/encoding/json/encode.go b/src/pkg/encoding/json/encode.go
index 5e8020502f..a112707269 100644
--- a/src/pkg/encoding/json/encode.go
+++ b/src/pkg/encoding/json/encode.go
@@ -734,7 +734,7 @@ func (e *encodeState) string(s string) (int, error) {
start := 0
for i := 0; i < len(s); {
if b := s[i]; b < utf8.RuneSelf {
- if 0x20 <= b && b != '\\' && b != '"' && b != '<' && b != '>' {
+ if 0x20 <= b && b != '\\' && b != '"' && b != '<' && b != '>' && b != '&' {
i++
continue
}