diff --git a/input.css b/input.css index 994aa15..f1eb8a6 100644 --- a/input.css +++ b/input.css @@ -300,6 +300,26 @@ margin-bottom: 0; } + /* 任务列表:pulldown-cmark 把 - [ ] / - [x] 渲染成裸
  • … + * (无
  • 文本
  • "#; + let result = clean_html(input); + assert!( + !result.contains("input"), + "type=image 的 input 必须被整体移除, got: {result}" + ); + assert!( + !result.contains("evil.example"), + "残留的 src 也应随 input 一并移除, got: {result}" + ); + // 文本内容保留 + assert!(result.contains("文本")); + } + + #[test] + fn clean_html_input_rejects_type_text() { + let result = clean_html(r#""#); + assert!( + !result.contains("input"), + "type=text 的 input 应被移除, got: {result}" + ); + } + + #[test] + fn clean_html_input_without_type_removed() { + // 缺省 type 属性的 input(如 经属性过滤后 type 缺省)必须整体移除 + let result = clean_html(""); + assert!( + !result.contains("input"), + "无 type 属性的 input 应被整体移除, got: {result}" + ); + } + + #[test] + fn clean_comment_html_input_stripped() { + // 评论白名单本就不含 input,任务列表 checkbox 在评论侧不放开 + let result = clean_comment_html(r#""#); + assert!( + !result.contains("input"), + "评论侧 input 应被剥离, got: {result}" + ); + } }