-
Notifications
You must be signed in to change notification settings - Fork 39
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
cmark_resume
panics when provided a crafted input
#91
Comments
Thanks a lot for pointing this out! I have removed these assertions and unwraps in favor of doing nothing instead. Here is the new release: https://github.com/Byron/pulldown-cmark-to-cmark/releases/tag/v19.0.1 |
Thanks @kdarkhan for reporting this! Looking at the events, it seems odd that there are two start tags after each other? The fuzz test that crashed is the So in other words: is there perhaps a bug in pulldown-cmark since it generated two header start events right after each other? Or is this just an artifact of how you reduced the test case to trigger the panic in this crate? |
Hi all! I had a look at the fuzzer crash. A de-obscured version of the minimized test case is:
Note that, by itself, While the initial input is valid Markdown, it becomes an invalid stream of I would say this isn't really a bug, more that the user did something nasty. So, in a way, panicking is probably more "correct" than failing silently? I assume that, if something like this happens, it would be a benign mistake made by the translator, and they'd rather know that something is wrong than get a book with inexplicably broken formatting. Still, panicking doesn't give much of an indication of what went wrong. I propose to revert #92 and replace panics with more structrured error handling. For example: pub enum ResumeError {
FormatFailed(fmt::Error),
UnexpectedEvent,
} and returning a |
Hi @cip999, Thank you so much for the investigation! This is very useful to me and my project!
Oh, yes, that makes sense!
Yes, in this context that is a great description: the mdbook-i18n-helpers system is very much relying on translators not inserting "extra" markup into their translations. To recap, the situation that caused this to crash cannot occur in the wild since it represents an impossible document where hello
--- is translated into world
---
--- and where this "double header" is parsed as two headers. In reality, this would be parsed as a header followed by a
That sounds like a good idea to 👍 |
Happy to help, I find this perfect to get started on contributing to Rust projects. 🙂
Precisely, this couldn't happen by means of pure text substitution.
Cool, I'll maybe send a PR here so the maintainers can form a better idea of the proposed change. |
Thanks everyone! I am absolutely looking forward to that PR! |
I expect https://github.com/google/mdbook-i18n-helpers/ will need an update after this to handle the newly returned error. @kdarkhan or I will eventually get to it, but you're very welcome to try your new Rust knowledge there as well 😄 |
Alternative approach for #91 with custom error type
Thanks @Byron for merging!
I think upgrading the dependency is non-breaking since right now it's always I'll get to that soon! Let's move the conversation to the other repo. 🙂 |
Here is a minimal test:
It results in a panic:
The failure was found by oss fuzzer in this run.
The text was updated successfully, but these errors were encountered: