From 0290f4d2e76318da8f08c886f90a13845bb08d8c Mon Sep 17 00:00:00 2001 From: xfy Date: Wed, 3 Jun 2026 10:09:14 +0800 Subject: [PATCH] fix(api): remove debug logging that caused UTF-8 boundary panic; configure ammonia to preserve anchor attributes --- src/api/posts.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/api/posts.rs b/src/api/posts.rs index 2458895..31d8f74 100644 --- a/src/api/posts.rs +++ b/src/api/posts.rs @@ -173,8 +173,15 @@ fn clean_html(input: &str) -> String { .add_generic_attributes(&["class", "aria-hidden", "aria-label", "id", "role", "accesskey", "title"]) .add_tags(&["details", "summary"]) .url_relative(ammonia::UrlRelative::PassThrough) - .clean(input) - .to_string() + .add_tag_attributes("a", &["class", "aria-hidden", "aria-label"]) + .add_tag_attributes("h1", &["id", "class"]) + .add_tag_attributes("h2", &["id", "class"]) + .add_tag_attributes("h3", &["id", "class"]) + .add_tag_attributes("h4", &["id", "class"]) + .add_tag_attributes("h5", &["id", "class"]) + .add_tag_attributes("h6", &["id", "class"]); + + builder.clean(input).to_string() } #[derive(Debug, Clone)]