PoiScript / orgize

A Rust library for parsing org-mode files.
https://poiscript.github.io/orgize/
MIT License
278 stars 34 forks source link

Crashes related to numbers, empty lists, and whitespace preceeding a headline #11

Closed calmofthestorm closed 4 years ago

calmofthestorm commented 4 years ago

Thank you for fixing the crashes I've reported so far, I appreciate you taking the time. I found a few more crashes in orgize 0.8.2 when trying to parse all my org files, and have produced minimized examples below. I think that these are all the crashes that are left from my personal org files, though of course it is hard to be sure.

fn main() {
    let crashes = &[
        // Number with a . and whitespace.
        "0. ",
        "* \n0. ",
        " 0. ",

        // Whitespace at start of line then *.
        " * ",
        "\t* ",

        // Seems to be an issue with lists with empty elements.
        "- ",
        "- hello\n- ",
        "- \n- hello",
        "- hello\n- \n- world",
        "* world\n- ",
    ];

    for crash in crashes {
        let crash = crash.to_string();
        assert!(std::thread::spawn(move || {
            let _ = orgize::Org::parse(&crash);
        })
        .join()
        .is_err())
    }

    println!("\n\n\n");
    println!("***");
    println!("*** All examples did/did not panic as expected, regardless the presence of panics printed above.");
    println!("***");
}
PoiScript commented 4 years ago

Fixed by v0.8.3.