Skip to content

Commit

Permalink
cbor: decode tags.
Browse files Browse the repository at this point in the history
(Partially) fixes #7.

The tag info is currently not retained, but this simple fix to parsing means we can at least consume and decode the rest of a cbor object containing (single-at-a-time) tags.

Signed-off-by: Eric Myhre <hash@exultant.us>
  • Loading branch information
warpfork committed Oct 15, 2017
1 parent 3df1bf6 commit f37c5c4
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions cbor/cborDecoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,24 @@ func (d *Decoder) stepHelper_acceptValue(majorByte byte, tokenSlot *Token) (done
d.pushPhase(d.step_acceptMapKey)
return false, err
case majorByte >= cborMajorTag && majorByte < cborMajorSimple:
return true, fmt.Errorf("cbor tags not supported")
// but when we do, it'll be by saving it as another field of the Token, and recursing.
// CBOR tags are, frankly, bonkers, and should not be used.
// They break isomorphism to basic standards like JSON.
// We'll parse basic integer tag values -- SINGLE layer only.
// We will NOT parse the full gamut of recursive tags: doing so
// would mean allowing an unbounded number of allocs *during
// *processing of a single token*, which is _not reasonable_.
_, err = d.decodeLen(majorByte)
if err != nil {
return true, err
}
// Okay, we slurped a tag.
// And dropped it on the floor. Because screw tags.
// Read next value.
majorByte, err := d.r.Readn1()
if err != nil {
return true, err
}
return d.stepHelper_acceptValue(majorByte, tokenSlot)
default:
return true, fmt.Errorf("Invalid majorByte: 0x%x", majorByte)
}
Expand Down

0 comments on commit f37c5c4

Please sign in to comment.