Skip to content
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

Add ability to disable/set depth limit #25

Open
MarshalX opened this issue Feb 24, 2024 · 3 comments
Open

Add ability to disable/set depth limit #25

MarshalX opened this issue Feb 24, 2024 · 3 comments

Comments

@MarshalX
Copy link

MarshalX commented Feb 24, 2024

Hello! cbor4ii's decoder comes with deep limit which could be disabled/increased by implementing own dec::Read. But serde_ipld_dagcbor implements it's own including deep limit. So I'm wondering is there any simple way to disable/increase it? For now i just copied de.rs to my codebase which is not pretty

I use serde_ipld_dagcbor like this:

//! Read a general CBOR value with an unknown content.
//!
//! ```rust
//! use serde_ipld_dagcbor::from_slice;
//! use libipld_core::ipld::Ipld;
//!
//! let slice = b"\x82\x01\xa1aaab";
//! let value: Ipld = from_slice(slice).unwrap();
//! println!("{:?}", value); // List([Integer(1), Map({"a": String("b")})])
//! ```

upd. as i understand serde_ipld_dagcbor doesn't tune depth limit at all. so the default (256) comes from cbor4ii. which is too small for me

@vmx
Copy link
Member

vmx commented Mar 1, 2024

@MarshalX would it help if the Deserializer would be public? I think then you could implement it for your own reader with your own limits.

vmx added a commit that referenced this issue Mar 14, 2024
The `Codec` trait from `ipld-core` allows unified access for encoding,
decoding and extracting links of encoded IPLD data independent of the
codec.

This commit also makes the `Deserializer` public, so that it can be
used for `ipld-extract-links`. Having it public should also help with
issue #25.
vmx added a commit that referenced this issue Mar 14, 2024
The `Codec` trait from `ipld-core` allows unified access for encoding,
decoding and extracting links of encoded IPLD data independent of the
codec. It only works when the `no-cid-as-bytes` feature is disabled,
because the link extraction code is based on Serde.

This commit also makes the `Deserializer` public, so that it can be
used for `ipld-extract-links`. Having it public should also help with
issue #25.
vmx added a commit that referenced this issue Mar 14, 2024
The `Codec` trait from `ipld-core` allows unified access for encoding,
decoding and extracting links of encoded IPLD data independent of the
codec. It only works when the `no-cid-as-bytes` feature is disabled,
because the link extraction code is based on Serde.

This commit also makes the `Deserializer` public, so that it can be
used for `ipld-extract-links`. Having it public should also help with
issue #25.
@vmx
Copy link
Member

vmx commented Mar 26, 2024

@MarshalX In the most recent release is the Deserializer public. Did you have have chance to see if setting the depth limit now works for you?

@MarshalX
Copy link
Author

MarshalX commented Mar 27, 2024

hi @vmx and thank you for your effort! i'm a bit busy these days but i'll try to verify as soon as i can. sorry for the long response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants