From cd3ee851a39675ca3675d0933328c48745e5c47f Mon Sep 17 00:00:00 2001 From: black_desk Date: Thu, 2 Sep 2021 17:46:46 +0800 Subject: [PATCH] Check object path --- encoder.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/encoder.go b/encoder.go index dbfb299..296de00 100644 --- a/encoder.go +++ b/encoder.go @@ -124,6 +124,11 @@ func (enc *encoder) encode(v reflect.Value, depth int) { if strings.IndexByte(str, byte(0)) != -1 { panic(FormatError("input has a null char('\\000') in string")) } + if v.Type() == objectPathType { + if !ObjectPath(str).IsValid() { + panic(FormatError("invalid object path")) + } + } enc.encode(reflect.ValueOf(uint32(len(str))), depth) b := make([]byte, v.Len()+1) copy(b, str)