Skip to main content

Module sanitizer

Module sanitizer 

Source
Expand description

HTML 消毒器。 HTML 消毒器。

基于 lol_html 清理不受信任的 HTML,限制允许的 tag/attribute/URL scheme, 分别提供文章正文(clean_html)与评论(clean_comment_html)两套白名单策略。 仅在 feature = "server" 时执行。

Structs§

SanitizerConfig 🔒
HTML 消毒配置:白名单 tag/attribute、允许 URL scheme 与链接 rel。

Statics§

CLEAN_CONTENT_TAGS 🔒
COMMENT_ALLOWED_TAGS 🔒
评论允许的标签:在默认集合基础上移除 img / details / summary。
DEFAULT_ALLOWED_SCHEMES 🔒
DEFAULT_ALLOWED_TAGS 🔒

Functions§

clean_comment_html
评论 HTML 清理:移除图片与折叠块,禁用 data URI,外链添加 nofollow noopener
clean_html
文章正文 HTML 清理:允许较完整的标签与 data URI,外链添加 noopener noreferrer
is_safe_data_uri 🔒
判断 data URI 是否属于安全图片类型。
is_safe_url 🔒
sanitize 🔒