Skip to content

Commit bf63549

Browse files
committed
Auto merge of #3297 - Turbo87:markdown-align, r=locks
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.
2 parents eb093ee + 06660eb commit bf63549

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/render.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ impl<'a> MarkdownRenderer<'a> {
4949
html_sanitizer
5050
.add_tags(&["input"])
5151
.link_rel(Some("nofollow noopener noreferrer"))
52+
.add_generic_attributes(&["align"])
5253
.add_tag_attributes("a", &["id", "target"])
5354
.add_tag_attributes("input", &["checked", "disabled", "type"])
5455
.allowed_classes(allowed_classes)
@@ -510,4 +511,14 @@ mod tests {
510511
"<table><tbody><tr><th rowspan=\"1\" colspan=\"2\">Target</th></tr></tbody></table>\n"
511512
);
512513
}
514+
515+
#[test]
516+
fn text_alignment() {
517+
let text = "<h1 align=\"center\">foo-bar</h1>\n<h5 align=\"center\">Hello World!</h5>\n";
518+
let result = markdown_to_html(text, None);
519+
assert_eq!(
520+
result,
521+
"<h1 align=\"center\">foo-bar</h1>\n<h5 align=\"center\">Hello World!</h5>\n"
522+
);
523+
}
513524
}

0 commit comments

Comments
 (0)