summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/vmihailenco/msgpack/v5/decode_string.go
diff options
context:
space:
mode:
authordependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2022-01-18 20:24:14 +0100
committerGitHub <noreply@github.com>2022-01-18 20:24:14 +0100
commitaad60c882e16cd2c8769a49e6d9f87a040590d62 (patch)
tree3bfe1f8953b40f9beb39c69db3a7647ea6de54d2 /vendor/github.com/vmihailenco/msgpack/v5/decode_string.go
parentfecca575078a21dedb0cab213dde7fd97161c0fa (diff)
downloadmatterbridge-msglm-aad60c882e16cd2c8769a49e6d9f87a040590d62.tar.gz
matterbridge-msglm-aad60c882e16cd2c8769a49e6d9f87a040590d62.tar.bz2
matterbridge-msglm-aad60c882e16cd2c8769a49e6d9f87a040590d62.zip
Bump github.com/mattermost/mattermost-server/v6 from 6.1.0 to 6.3.0 (#1686)
Bumps [github.com/mattermost/mattermost-server/v6](https://github.com/mattermost/mattermost-server) from 6.1.0 to 6.3.0. - [Release notes](https://github.com/mattermost/mattermost-server/releases) - [Changelog](https://github.com/mattermost/mattermost-server/blob/master/CHANGELOG.md) - [Commits](https://github.com/mattermost/mattermost-server/compare/v6.1.0...v6.3.0) --- updated-dependencies: - dependency-name: github.com/mattermost/mattermost-server/v6 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Diffstat (limited to 'vendor/github.com/vmihailenco/msgpack/v5/decode_string.go')
-rw-r--r--vendor/github.com/vmihailenco/msgpack/v5/decode_string.go192
1 files changed, 192 insertions, 0 deletions
diff --git a/vendor/github.com/vmihailenco/msgpack/v5/decode_string.go b/vendor/github.com/vmihailenco/msgpack/v5/decode_string.go
new file mode 100644
index 00000000..e837e08b
--- /dev/null
+++ b/vendor/github.com/vmihailenco/msgpack/v5/decode_string.go
@@ -0,0 +1,192 @@
+package msgpack
+
+import (
+ "fmt"
+ "reflect"
+
+ "github.com/vmihailenco/msgpack/v5/msgpcode"
+)
+
+func (d *Decoder) bytesLen(c byte) (int, error) {
+ if c == msgpcode.Nil {
+ return -1, nil
+ }
+
+ if msgpcode.IsFixedString(c) {
+ return int(c & msgpcode.FixedStrMask), nil
+ }
+
+ switch c {
+ case msgpcode.Str8, msgpcode.Bin8:
+ n, err := d.uint8()
+ return int(n), err
+ case msgpcode.Str16, msgpcode.Bin16:
+ n, err := d.uint16()
+ return int(n), err
+ case msgpcode.Str32, msgpcode.Bin32:
+ n, err := d.uint32()
+ return int(n), err
+ }
+
+ return 0, fmt.Errorf("msgpack: invalid code=%x decoding string/bytes length", c)
+}
+
+func (d *Decoder) DecodeString() (string, error) {
+ if intern := d.flags&useInternedStringsFlag != 0; intern || len(d.dict) > 0 {
+ return d.decodeInternedString(intern)
+ }
+
+ c, err := d.readCode()
+ if err != nil {
+ return "", err
+ }
+ return d.string(c)
+}
+
+func (d *Decoder) string(c byte) (string, error) {
+ n, err := d.bytesLen(c)
+ if err != nil {
+ return "", err
+ }
+ return d.stringWithLen(n)
+}
+
+func (d *Decoder) stringWithLen(n int) (string, error) {
+ if n <= 0 {
+ return "", nil
+ }
+ b, err := d.readN(n)
+ return string(b), err
+}
+
+func decodeStringValue(d *Decoder, v reflect.Value) error {
+ s, err := d.DecodeString()
+ if err != nil {
+ return err
+ }
+ v.SetString(s)
+ return nil
+}
+
+func (d *Decoder) DecodeBytesLen() (int, error) {
+ c, err := d.readCode()
+ if err != nil {
+ return 0, err
+ }
+ return d.bytesLen(c)
+}
+
+func (d *Decoder) DecodeBytes() ([]byte, error) {
+ c, err := d.readCode()
+ if err != nil {
+ return nil, err
+ }
+ return d.bytes(c, nil)
+}
+
+func (d *Decoder) bytes(c byte, b []byte) ([]byte, error) {
+ n, err := d.bytesLen(c)
+ if err != nil {
+ return nil, err
+ }
+ if n == -1 {
+ return nil, nil
+ }
+ return readN(d.r, b, n)
+}
+
+func (d *Decoder) decodeStringTemp() (string, error) {
+ if intern := d.flags&useInternedStringsFlag != 0; intern || len(d.dict) > 0 {
+ return d.decodeInternedString(intern)
+ }
+
+ c, err := d.readCode()
+ if err != nil {
+ return "", err
+ }
+
+ n, err := d.bytesLen(c)
+ if err != nil {
+ return "", err
+ }
+ if n == -1 {
+ return "", nil
+ }
+
+ b, err := d.readN(n)
+ if err != nil {
+ return "", err
+ }
+
+ return bytesToString(b), nil
+}
+
+func (d *Decoder) decodeBytesPtr(ptr *[]byte) error {
+ c, err := d.readCode()
+ if err != nil {
+ return err
+ }
+ return d.bytesPtr(c, ptr)
+}
+
+func (d *Decoder) bytesPtr(c byte, ptr *[]byte) error {
+ n, err := d.bytesLen(c)
+ if err != nil {
+ return err
+ }
+ if n == -1 {
+ *ptr = nil
+ return nil
+ }
+
+ *ptr, err = readN(d.r, *ptr, n)
+ return err
+}
+
+func (d *Decoder) skipBytes(c byte) error {
+ n, err := d.bytesLen(c)
+ if err != nil {
+ return err
+ }
+ if n <= 0 {
+ return nil
+ }
+ return d.skipN(n)
+}
+
+func decodeBytesValue(d *Decoder, v reflect.Value) error {
+ c, err := d.readCode()
+ if err != nil {
+ return err
+ }
+
+ b, err := d.bytes(c, v.Bytes())
+ if err != nil {
+ return err
+ }
+
+ v.SetBytes(b)
+
+ return nil
+}
+
+func decodeByteArrayValue(d *Decoder, v reflect.Value) error {
+ c, err := d.readCode()
+ if err != nil {
+ return err
+ }
+
+ n, err := d.bytesLen(c)
+ if err != nil {
+ return err
+ }
+ if n == -1 {
+ return nil
+ }
+ if n > v.Len() {
+ return fmt.Errorf("%s len is %d, but msgpack has %d elements", v.Type(), v.Len(), n)
+ }
+
+ b := v.Slice(0, n).Bytes()
+ return d.readFull(b)
+}