Skip to content

Commit

Permalink
Auto merge of #3297 - Turbo87:markdown-align, r=locks
Browse files Browse the repository at this point in the history
README: Allow `align` attributes

Resolves #2151

As far as I'm aware there is no way that this could be used in any malicious way and `align` is already allowed on e.g. `img` elements by default in the `ammonia` crate.
  • Loading branch information
bors committed Feb 25, 2021
2 parents eb093ee + 06660eb commit bf63549
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ impl<'a> MarkdownRenderer<'a> {
html_sanitizer
.add_tags(&["input"])
.link_rel(Some("nofollow noopener noreferrer"))
.add_generic_attributes(&["align"])
.add_tag_attributes("a", &["id", "target"])
.add_tag_attributes("input", &["checked", "disabled", "type"])
.allowed_classes(allowed_classes)
Expand Down Expand Up @@ -510,4 +511,14 @@ mod tests {
"<table><tbody><tr><th rowspan=\"1\" colspan=\"2\">Target</th></tr></tbody></table>\n"
);
}

#[test]
fn text_alignment() {
let text = "<h1 align=\"center\">foo-bar</h1>\n<h5 align=\"center\">Hello World!</h5>\n";
let result = markdown_to_html(text, None);
assert_eq!(
result,
"<h1 align=\"center\">foo-bar</h1>\n<h5 align=\"center\">Hello World!</h5>\n"
);
}
}

0 comments on commit bf63549

Please sign in to comment.