diff options
author | Vika <vika@fireburn.ru> | 2025-01-02 14:12:08 +0300 |
---|---|---|
committer | Vika <vika@fireburn.ru> | 2025-01-02 14:12:08 +0300 |
commit | 37c1becdf506fd1effc2dbc6079192cb98eaaacd (patch) | |
tree | 7dbc99540f5d784bdffb4239b89bc95536f1b77e /src/micropub | |
parent | b0b4c08ffc6bd86a16851f97ee5740791c40d08e (diff) | |
download | kittybox-37c1becdf506fd1effc2dbc6079192cb98eaaacd.tar.zst |
Allow arbitrary HTML in Markdown post content
Oh, that's how it's done. Fuck. Change-Id: I40c5296ba05ddec7aa277308520017e5068e6fc9
Diffstat (limited to 'src/micropub')
-rw-r--r-- | src/micropub/util.rs | 12 |
1 files changed, 11 insertions, 1 deletions
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] }]) } |