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

panic on input * #42

Closed
makemeunsee opened this issue Jan 18, 2023 · 10 comments
Closed

panic on input * #42

makemeunsee opened this issue Jan 18, 2023 · 10 comments

Comments

@makemeunsee
Copy link

makemeunsee commented Jan 18, 2023

Hello,

This input * (without the double quotes) causes markdown::to_html to panic.

e.g.

fn main() {
    println!("{}", markdown::to_html("* "));
}

Just in case, I've pasted the stacktrace below.

Cheers, let me know if I can provide anything else to help.

thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', /home/me/.cargo/registry/src/github.com-1ecc6299db9ec823/markdown-0.3.0/src/parser/block/unordered_list.rs:84:44
stack backtrace:
0: rust_begin_unwind
at /rustc/96ddd32c4bfb1d78f0cd03eb068b1710a8cebeef/library/std/src/panicking.rs:575:5
1: core::panicking::panic_fmt
at /rustc/96ddd32c4bfb1d78f0cd03eb068b1710a8cebeef/library/core/src/panicking.rs:65:14
2: core::panicking::panic_bounds_check
at /rustc/96ddd32c4bfb1d78f0cd03eb068b1710a8cebeef/library/core/src/panicking.rs:150:5
3: <usize as core::slice::index::SliceIndex<[T]>>::index
at /rustc/96ddd32c4bfb1d78f0cd03eb068b1710a8cebeef/library/core/src/slice/index.rs:259:10
4: core::slice::index::<impl core::ops::index::Index for [T]>::index
at /rustc/96ddd32c4bfb1d78f0cd03eb068b1710a8cebeef/library/core/src/slice/index.rs:18:9
5: <alloc::vec::Vec<T,A> as core::ops::index::Index>::index
at /rustc/96ddd32c4bfb1d78f0cd03eb068b1710a8cebeef/library/alloc/src/vec/mod.rs:2736:9
6: markdown::parser::block::unordered_list::parse_unordered_list
at /home/me/.cargo/registry/src/github.com-1ecc6299db9ec823/markdown-0.3.0/src/parser/block/unordered_list.rs:84:44
7: markdown::parser::block::parse_block
at /home/me/.cargo/registry/src/github.com-1ecc6299db9ec823/markdown-0.3.0/src/parser/block/mod.rs:71:5
8: markdown::parser::block::parse_blocks
at /home/me/.cargo/registry/src/github.com-1ecc6299db9ec823/markdown-0.3.0/src/parser/block/mod.rs:27:15
9: markdown::parser::parse
at /home/me/.cargo/registry/src/github.com-1ecc6299db9ec823/markdown-0.3.0/src/parser/mod.rs:43:5
10: markdown::to_html
at /home/me/.cargo/registry/src/github.com-1ecc6299db9ec823/markdown-0.3.0/src/lib.rs:29:18
11: markdown_bug::main
at ./frontend/examples/markdown_bug.rs:2:20
12: core::ops::function::FnOnce::call_once
at /rustc/96ddd32c4bfb1d78f0cd03eb068b1710a8cebeef/library/core/src/ops/function.rs:513:5

@makemeunsee makemeunsee changed the title panic on input * panic on input * Jan 18, 2023
@ChristianMurphy
Copy link
Collaborator

@makemeunsee could you share a runnable example of the issue?
I tried the sample code you provided with version 1.0.0-alpha.5 and do not see a panic.

Runnable example https://www.rustexplorer.com/b#%2F*%0A%5Bdependencies%5D%0Amarkdown%20%3D%20%221.0.0-alpha.5%22%0A*%2F%0A%0Ause%20markdown%3B%0A%0Afn%20main()%20%7B%0A%20%20%20%20println!(%22%7B%7D%22%2C%20markdown%3A%3Ato_html(%22*%20%22))%3B%0A%7D

source from example
/*
[dependencies]
markdown = "1.0.0-alpha.5"
*/

use markdown;

fn main() {
    println!("{}", markdown::to_html("* "));
}

@wooorm
Copy link
Owner

wooorm commented Jan 18, 2023

Wrong package. You’re using the old one, that has tons of problems. This is a completely new project with the same name.

@wooorm wooorm closed this as not planned Won't fix, can't repro, duplicate, stale Jan 18, 2023
@makemeunsee
Copy link
Author

Oh, my bad! Thanks for pointing it out.

@makemeunsee
Copy link
Author

Note:

https://crates.io/crates/markdown still advertises 0.3.0 as the latest, indicates it was last released 2 years ago.

The crates VS code plugin also points to 0.3.0 as the latest. If you have a way to force these external services, I believe it would help with the project visibility and potential confusion.

@wooorm
Copy link
Owner

wooorm commented Jan 18, 2023

There is no force. crates doesn’t show alpha releases by default.

@wooorm
Copy link
Owner

wooorm commented Jan 18, 2023

As far as I know, at least! If you know of a way to get around it, I’d love to hear

@makemeunsee
Copy link
Author

No, I'm not aware of anything of the sort, unfortunately. How close do you think this crate is to not being alpha anymore? Do you have a roadmap for the v1? Curious and potentially happy to help...

@wooorm
Copy link
Owner

wooorm commented Jan 20, 2023

I want to switch unist nodes towards traits, so that ToString, children, children_mut, position, etc here would be traits, which mdast/hast implement. That’s the only breaking change (perhaps also GH-40) I’d want to do first!

If you want to work on that, that would be much appreciated!

@makemeunsee
Copy link
Author

makemeunsee commented Jan 21, 2023

I started having a look and trying to wrap my head around the problem/intent.

Is there already an issue open where to discuss? I found about this comment of yours but it's just a mention of this plan, not the dedicate channel to discuss it, no?

@wooorm
Copy link
Owner

wooorm commented Jan 23, 2023

No, there is no particular issue or dedicated channel. Feel free to open one or discuss here!

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

3 participants