Skip to content

Panic with ENABLE_DEFINITION_LIST #1142

Closed

Description

@langston-barrett

Found by a fuzzer. I didn't see duplicates in the issue tracker. Feel free to close if this isn't helpful / a priority!

// Cargo.toml: pulldown-cmark = "0.13.4"
use pulldown_cmark::{Options, Parser};

fn main() {
    // "%\n:\u{301}\n\t:"  ==  b"%\n:\xcc\x81\n\t:"   (8 bytes)
    //   %          definition-list title
    //   :U+0301    a definition whose text is a 2-byte combining acute
    //   \t:        a second definition, introduced by a TAB
    let doc = "%\n:\u{301}\n\t:";
    let opts = Options::ENABLE_DEFINITION_LIST;

    for (_event, range) in Parser::new_ext(doc, opts).into_offset_iter() {
        // Start/End(DefinitionListDefinition) report 4..8; byte 4 is inside U+0301.
        // panics: start byte index 4 is not a char boundary
        let _src: &str = &doc[range];
    }
}
thread 'main' (382438) panicked at src/main.rs:14:30:
start byte index 4 is not a char boundary; it is inside '\u{301}' (bytes 3..5 of string)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions