PoiScript / orgize

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

Crash when parsing unmatched * or / #10

Closed calmofthestorm closed 4 years ago

calmofthestorm commented 4 years ago

Hi,

I found a crash related to unmatched * and /. I didn't check any other Org formatting markers, but they may likewise be affected. I am using orgize 0.8.1.

fn main() {
    let crashes = &[
        "* / // a",
        "\"* / // a\"",
        "* * ** a",
        "* 2020\n** December\n*** Experiment\nType A is marked with * and type B is marked with **.\n",
        "* 2020\n:DRAWER:\n* ** a\n:END:",
    ];

    let okies = &["* * ** :a:", "* * ** "];

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

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

    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

Thanks for reporting this. It has been fixed by v0.8.2.

calmofthestorm commented 4 years ago

Thanks so much for the fast fix!