summaryrefslogtreecommitdiff
path: root/vendor/github.com/fxamacker/cbor/v2/bytestring.go
diff options
context:
space:
mode:
authorFelix Hanley <felix@userspace.com.au>2025-08-28 01:38:06 +0000
committerFelix Hanley <felix@userspace.com.au>2025-08-28 01:38:06 +0000
commit02e6f97cd04cbcd7505e1da9a781df4321463640 (patch)
tree08d3d2317cdab4885d7c9830ed7983fecfb9fb4a /vendor/github.com/fxamacker/cbor/v2/bytestring.go
parentfaa33e32b5e967fdfeac96bfc39ed3d94f9514ac (diff)
downloadcaddy-02e6f97cd04cbcd7505e1da9a781df4321463640.tar.gz
caddy-02e6f97cd04cbcd7505e1da9a781df4321463640.tar.bz2
Attempt to stop AI bots using Anubis
Diffstat (limited to 'vendor/github.com/fxamacker/cbor/v2/bytestring.go')
-rw-r--r--vendor/github.com/fxamacker/cbor/v2/bytestring.go31
1 files changed, 29 insertions, 2 deletions
diff --git a/vendor/github.com/fxamacker/cbor/v2/bytestring.go b/vendor/github.com/fxamacker/cbor/v2/bytestring.go
index 52a28ed..23c5724 100644
--- a/vendor/github.com/fxamacker/cbor/v2/bytestring.go
+++ b/vendor/github.com/fxamacker/cbor/v2/bytestring.go
@@ -22,8 +22,8 @@ func (bs ByteString) Bytes() []byte {
// MarshalCBOR encodes ByteString as CBOR byte string (major type 2).
func (bs ByteString) MarshalCBOR() ([]byte, error) {
- e := getEncoderBuffer()
- defer putEncoderBuffer(e)
+ e := getEncodeBuffer()
+ defer putEncodeBuffer(e)
// Encode length
encodeHead(e, byte(cborTypeByteString), uint64(len(bs)))
@@ -38,11 +38,38 @@ func (bs ByteString) MarshalCBOR() ([]byte, error) {
// UnmarshalCBOR decodes CBOR byte string (major type 2) to ByteString.
// Decoding CBOR null and CBOR undefined sets ByteString to be empty.
+//
+// Deprecated: No longer used by this codec; kept for compatibility
+// with user apps that directly call this function.
func (bs *ByteString) UnmarshalCBOR(data []byte) error {
if bs == nil {
return errors.New("cbor.ByteString: UnmarshalCBOR on nil pointer")
}
+ d := decoder{data: data, dm: defaultDecMode}
+
+ // Check well-formedness of CBOR data item.
+ // ByteString.UnmarshalCBOR() is exported, so
+ // the codec needs to support same behavior for:
+ // - Unmarshal(data, *ByteString)
+ // - ByteString.UnmarshalCBOR(data)
+ err := d.wellformed(false, false)
+ if err != nil {
+ return err
+ }
+
+ return bs.unmarshalCBOR(data)
+}
+
+// unmarshalCBOR decodes CBOR byte string (major type 2) to ByteString.
+// Decoding CBOR null and CBOR undefined sets ByteString to be empty.
+// This function assumes data is well-formed, and does not perform bounds checking.
+// This function is called by Unmarshal().
+func (bs *ByteString) unmarshalCBOR(data []byte) error {
+ if bs == nil {
+ return errors.New("cbor.ByteString: UnmarshalCBOR on nil pointer")
+ }
+
// Decoding CBOR null and CBOR undefined to ByteString resets data.
// This behavior is similar to decoding CBOR null and CBOR undefined to []byte.
if len(data) == 1 && (data[0] == 0xf6 || data[0] == 0xf7) {