mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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:
parent
fb63e4fefb
commit
d754647963
4 changed files with 60 additions and 6 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue