hildjj / node-cbor

Encode and decode CBOR documents, with both easy mode, streaming mode, and SAX-style evented mode.
MIT License
357 stars 73 forks source link

decodeFirstSync does not throw error for unused bytes #111

Closed ashisherc closed 4 years ago

ashisherc commented 4 years ago
try {
cbor.decodeFirstSync("01f3d81803d9b0ac6a56004d5d6117eed4857b95c33a6de2c7bcc234492f2b32409e0aa015d2407ab37dd671c21ea7a189d5a9163abc30d107");
  } catch (error) {
    // no error
  }

while using cbor.decodeFirst does throw error about invalid f3 after 01,

The expected behaviour is to throw an error to be able to catch in the catch block.

hildjj commented 4 years ago

I agree that decodeFirst and decodeFirstSync should do the same thing. This is an edge-case breaking change, so I'll update the minor version number in response.

hildjj commented 4 years ago

Fixed in v5.1.0