diff --git a/src/utils/html.rs b/src/utils/html.rs index 1652cc8..a1635cc 100644 --- a/src/utils/html.rs +++ b/src/utils/html.rs @@ -6,6 +6,8 @@ pub fn clean_html(unsafe_html: &str) -> String { let mut allowed_tags = HashSet::new(); allowed_tags.insert("a"); allowed_tags.insert("br"); + allowed_tags.insert("pre"); + allowed_tags.insert("code"); let safe_html = Builder::default() .tags(allowed_tags) @@ -20,8 +22,8 @@ mod tests { #[test] fn test_clean_html() { - let unsafe_html = r#"

test bold with link

"#; + let unsafe_html = r#"

test bold with link and code

"#; let safe_html = clean_html(unsafe_html); - assert_eq!(safe_html, r#"test bold with link"#); + assert_eq!(safe_html, r#"test bold with link and code"#); } }