encoding/json: escape U+2028 and U+2029.

Fixes #5836.

R=golang-dev, bradfitz, r, rsc
CC=golang-dev
https://golang.org/cl/10883045
This commit is contained in:
David Symonds 2013-07-12 14:35:55 +10:00
parent fb63e4fefb
commit d754647963
4 changed files with 60 additions and 6 deletions

View file

@ -568,14 +568,14 @@ func TestUnmarshalPtrPtr(t *testing.T) {
}
func TestEscape(t *testing.T) {
const input = `"foobar"<html>`
const expected = `"\"foobar\"\u003chtml\u003e"`
const input = `"foobar"<html>` + " [\u2028 \u2029]"
const expected = `"\"foobar\"\u003chtml\u003e [\u2028 \u2029]"`
b, err := Marshal(input)
if err != nil {
t.Fatalf("Marshal error: %v", err)
}
if s := string(b); s != expected {
t.Errorf("Encoding of [%s] was [%s], want [%s]", input, s, expected)
t.Errorf("Encoding of [%s]:\n got [%s]\nwant [%s]", input, s, expected)
}
}