aboutsummaryrefslogtreecommitdiffstats
path: root/tests/misc_dangerous_html.rs
blob: 6bc73d84e85104d5212902051a763d1762c42738 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
extern crate micromark;
use micromark::{micromark, micromark_with_options, Options};
use pretty_assertions::assert_eq;

#[test]
fn dangerous_html() {
    let danger = &Options {
        allow_dangerous_html: true,
        allow_dangerous_protocol: true,
        ..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`"
    );
}