From 37c1becdf506fd1effc2dbc6079192cb98eaaacd Mon Sep 17 00:00:00 2001 From: Vika Date: Thu, 2 Jan 2025 14:12:08 +0300 Subject: Allow arbitrary HTML in Markdown post content Oh, that's how it's done. Fuck. Change-Id: I40c5296ba05ddec7aa277308520017e5068e6fc9 --- src/micropub/util.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/micropub/util.rs b/src/micropub/util.rs index 9bbdcf6..19f4953 100644 --- a/src/micropub/util.rs +++ b/src/micropub/util.rs @@ -94,7 +94,17 @@ pub fn normalize_mf2(mut body: serde_json::Value, user: &TokenData) -> (String, if body["properties"]["content"][0].is_string() { // Convert the content to HTML using the `markdown` crate body["properties"]["content"] = json!([{ - "html": markdown::to_html(body["properties"]["content"][0].as_str().unwrap()), + "html": markdown::to_html_with_options( + body["properties"]["content"][0].as_str().unwrap(), + &markdown::Options { + compile: markdown::CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: false, + ..Default::default() + }, + parse: markdown::ParseOptions::default() + } + ).unwrap(), "value": body["properties"]["content"][0] }]) } -- cgit 1.4.1