aboutsummaryrefslogblamecommitdiffstats
path: root/tests/misc_dangerous_html.rs
blob: 9787813a66e1d7f3995c86eb7e981ed722c73bc1 (plain) (tree)
1
2
3
4
5
6
7
                       
                                                                            
                                 
 
       
                                           
                           




                                           


                            












                                            
                                               


                                                  

          
 
extern crate micromark;
use micromark::{micromark, micromark_with_options, CompileOptions, Options};
use pretty_assertions::assert_eq;

#[test]
fn dangerous_html() -> Result<(), String> {
    let danger = &Options {
        compile: CompileOptions {
            allow_dangerous_html: true,
            allow_dangerous_protocol: true,
            ..CompileOptions::default()
        },
        ..Options::default()
    };

    assert_eq!(
        micromark("<x>"),
        "&lt;x&gt;",
        "should be safe by default for flow"
    );

    assert_eq!(
        micromark("a<b>"),
        "<p>a&lt;b&gt;</p>",
        "should be safe by default for text"
    );

    assert_eq!(
        micromark_with_options("<x>", danger)?,
        "<x>",
        "should be unsafe w/ `allowDangerousHtml`"
    );

    Ok(())
}