summaryrefslogtreecommitdiffstats
path: root/llgo/third_party/gofrontend/libgo/go/encoding/json/encode.go
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2015-04-05 23:30:42 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2015-04-05 23:30:42 +0000
commit93c73ebcbd73f5436d13ffc41f49a86fc062deb8 (patch)
tree10bf9fb3a1314fc8a1c3b963b4550960718384ad /llgo/third_party/gofrontend/libgo/go/encoding/json/encode.go
parent7d39641c805bf3263ffb55a23ecf4bbfd37402c0 (diff)
downloadbcm5719-llvm-93c73ebcbd73f5436d13ffc41f49a86fc062deb8.tar.gz
bcm5719-llvm-93c73ebcbd73f5436d13ffc41f49a86fc062deb8.zip
Roll gofrontend to a6e10414311a
This takes us to Go 1.4. Also includes a couple of changes to the test suite, both in the runtime package: - Disable TestSetPanicOnFault. We cannot support this scenario at all, due to LLVM's lack of non-call exceptions. - Tweak TestFinalizerType. This test only passes with two GC runs. Differential Revision: http://reviews.llvm.org/D8828 llvm-svn: 234134
Diffstat (limited to 'llgo/third_party/gofrontend/libgo/go/encoding/json/encode.go')
-rw-r--r--llgo/third_party/gofrontend/libgo/go/encoding/json/encode.go18
1 files changed, 13 insertions, 5 deletions
diff --git a/llgo/third_party/gofrontend/libgo/go/encoding/json/encode.go b/llgo/third_party/gofrontend/libgo/go/encoding/json/encode.go
index 741ddd89cbe..fca2a0980b2 100644
--- a/llgo/third_party/gofrontend/libgo/go/encoding/json/encode.go
+++ b/llgo/third_party/gofrontend/libgo/go/encoding/json/encode.go
@@ -40,8 +40,8 @@ import (
//
// Floating point, integer, and Number values encode as JSON numbers.
//
-// String values encode as JSON strings. InvalidUTF8Error will be returned
-// if an invalid UTF-8 sequence is encountered.
+// String values encode as JSON strings coerced to valid UTF-8,
+// replacing invalid bytes with the Unicode replacement rune.
// The angle brackets "<" and ">" are escaped to "\u003c" and "\u003e"
// to keep some browsers from misinterpreting JSON output as HTML.
// Ampersand "&" is also escaped to "\u0026" for the same reason.
@@ -93,6 +93,8 @@ import (
// as described in the next paragraph.
// An anonymous struct field with a name given in its JSON tag is treated as
// having that name, rather than being anonymous.
+// An anonymous struct field of interface type is treated the same as having
+// that type as its name, rather than being anonymous.
//
// The Go visibility rules for struct fields are amended for JSON when
// deciding which field to marshal or unmarshal. If there are
@@ -696,12 +698,12 @@ type ptrEncoder struct {
elemEnc encoderFunc
}
-func (pe *ptrEncoder) encode(e *encodeState, v reflect.Value, _ bool) {
+func (pe *ptrEncoder) encode(e *encodeState, v reflect.Value, quoted bool) {
if v.IsNil() {
e.WriteString("null")
return
}
- pe.elemEnc(e, v.Elem(), false)
+ pe.elemEnc(e, v.Elem(), quoted)
}
func newPtrEncoder(t reflect.Type) encoderFunc {
@@ -803,6 +805,9 @@ func (e *encodeState) string(s string) (int, error) {
case '\r':
e.WriteByte('\\')
e.WriteByte('r')
+ case '\t':
+ e.WriteByte('\\')
+ e.WriteByte('t')
default:
// This encodes bytes < 0x20 except for \n and \r,
// as well as <, > and &. The latter are escaped because they
@@ -876,9 +881,12 @@ func (e *encodeState) stringBytes(s []byte) (int, error) {
case '\r':
e.WriteByte('\\')
e.WriteByte('r')
+ case '\t':
+ e.WriteByte('\\')
+ e.WriteByte('t')
default:
// This encodes bytes < 0x20 except for \n and \r,
- // as well as < and >. The latter are escaped because they
+ // as well as <, >, and &. The latter are escaped because they
// can lead to security holes when user-controlled strings
// are rendered into JSON and served to some browsers.
e.WriteString(`\u00`)
OpenPOWER on IntegriCloud