diff options
author | Wim <wim@42.be> | 2019-03-05 23:08:54 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2019-03-05 23:10:45 +0100 |
commit | 325d62b41c03f0530513a4f404cc8d7349b6885b (patch) | |
tree | d6f9f2809bdcd3a35b696b412c24cf6f54ddab78 /vendor/github.com/d5/tengo/objects/conversion.go | |
parent | e955a056e2aa4a07c6375315113886b2ee86138c (diff) | |
download | matterbridge-msglm-325d62b41c03f0530513a4f404cc8d7349b6885b.tar.gz matterbridge-msglm-325d62b41c03f0530513a4f404cc8d7349b6885b.tar.bz2 matterbridge-msglm-325d62b41c03f0530513a4f404cc8d7349b6885b.zip |
Update vendor d5/tengo
Diffstat (limited to 'vendor/github.com/d5/tengo/objects/conversion.go')
-rw-r--r-- | vendor/github.com/d5/tengo/objects/conversion.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/vendor/github.com/d5/tengo/objects/conversion.go b/vendor/github.com/d5/tengo/objects/conversion.go index 3c17546f..714f2617 100644 --- a/vendor/github.com/d5/tengo/objects/conversion.go +++ b/vendor/github.com/d5/tengo/objects/conversion.go @@ -4,6 +4,8 @@ import ( "fmt" "strconv" "time" + + "github.com/d5/tengo" ) // ToString will try to convert object o to string value. @@ -194,6 +196,9 @@ func FromInterface(v interface{}) (Object, error) { case nil: return UndefinedValue, nil case string: + if len(v) > tengo.MaxStringLen { + return nil, ErrStringLimit + } return &String{Value: v}, nil case int64: return &Int{Value: v}, nil @@ -211,6 +216,9 @@ func FromInterface(v interface{}) (Object, error) { case float64: return &Float{Value: v}, nil case []byte: + if len(v) > tengo.MaxBytesLen { + return nil, ErrBytesLimit + } return &Bytes{Value: v}, nil case error: return &Error{Value: &String{Value: v.Error()}}, nil @@ -243,6 +251,8 @@ func FromInterface(v interface{}) (Object, error) { return &Time{Value: v}, nil case Object: return v, nil + case CallableFunc: + return &UserFunction{Value: v}, nil } return nil, fmt.Errorf("cannot convert to object: %T", v) |