-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow rejection of NaN and Inf float values on encode and decode. #513
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benluddy Thanks for opening this PR! It makes sense to add options to reject NaN and infinity for some use cases.
Encoding looks great!
For decoding, we can probably handle decoding options similar to way it is done for TagsMode
and IndefLengthMode
:
-
Handle new decoding options in
wellformedl()
instead of decoding functions, so codec can reject CBOR data early without allocating decoded objects. It would also simplify decoding function becausewellformed()
is called beforeparseToValue()
. -
Use the same naming convention (e.g.
TagsMode
has optionsTagsAllowed
andTagsForbidden
).
Thoughts?
Sounds great. I had been thinking to myself, "what if a user needs to distinguish between ill-formed input and well-formed input that is rejected by the application's protocol." Now I realize that that case can be served just fine by a second call to I'll implement your recommendations today. |
c6c93a1
to
7c776ec
Compare
Done. Please take another look when you have a chance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating this PR! I left some comments about checking CBOR type before converting to float.
D'oh! Thank you. Added test cases to catch that and fixed. |
Signed-off-by: Ben Luddy <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! 👍 Thanks for updating this PR!
Description
Implements #512 to allow users to error rather than encode or decode NaN and Inf floating-point values.
PR Was Proposed and Welcomed in Currently Open Issue
Checklist (for code PR only, ignore for docs PR)
Last line of each commit message should be in this format:
Signed-off-by: Firstname Lastname [email protected]
(see next section).
Certify the Developer's Certificate of Origin 1.1
the Developer Certificate of Origin 1.1.