sanitize
2,056
Stars
—
Forks
0
Watchers
—
Open Issues
待补全
许可证
Ruby
语言
—
创建时间
最近更新
项目能做什么
Ruby 语言编写的 HTML 与 CSS 内容清理消毒库。
来源:AI 基于仓库事实生成
· 内容以仓库实际 README 为准
使用说明 查看原始 README 原仓库文档
中文使用说明暂未生成。下面保留原仓库 README 摘录,命令与配置均以原文为准。
原始 README 摘录(英文原文,节选前 3000 字符)
# Sanitize Sanitize is an allowlist-based HTML and CSS sanitizer. It removes all HTML and/or CSS from a string except the elements, attributes, and properties you choose to allow. Using a simple configuration syntax, you can tell Sanitize to allow certain HTML elements, certain attributes within those elements, and even certain URL protocols within attributes that contain URLs. You can also allow specific CSS properties, @ rules, and URL protocols in elements or attributes containing CSS. Any HTML or CSS that you don't explicitly allow will be removed. Sanitize is based on the [Nokogiri HTML5 parser][nokogiri], which parses HTML the same way modern browsers do, and [Crass][crass], which parses CSS the same way modern browsers do. As long as your allowlist config only allows safe markup and CSS, even the most malformed or malicious input will be transformed into safe output. [](http://badge.fury.io/rb/sanitize) [](https://github.com/rgrove/sanitize/actions?query=workflow%3ATests) [crass]:https://github.com/rgrove/crass [nokogiri]:https://github.com/sparklemotion/nokogiri > [!WARNING] > > Sanitize cannot fully sanitize the contents of `<math>` or `<svg>` elements. MathML and SVG elements are [foreign elements](https://html.spec.whatwg.org/multipage/syntax.html#foreign-elements) that don't follow normal HTML parsing rules. > > By default, Sanitize will remove all MathML and SVG elements. If you add MathML or SVG elements to a custom element allowlist, you may create a security vulnerability in your application. ## Links * [Home](https://github.com/rgrove/sanitize/) * [API Docs](https://rubydoc.info/gems/sanitize/Sanitize) * [Issues](https://github.com/rgrove/sanitize/issues) * [Release History](https://github.com/rgrove/sanitize/releases) * [Online Demo](https://sanitize-web.fly.dev/) ## Installation ``` gem install sanitize ``` ## Quick Start ```ruby require 'sanitize' # Clean up an HTML fragment using Sanitize's permissive but safe Relaxed config. # This also sanitizes any CSS in `<style>` elements or `style` attributes. Sanitize.fragment(html, Sanitize::Config::RELAXED) # Clean up an HTML document using the Relaxed config. Sanitize.document(html, Sanitize::Config::RELAXED) # Clean up a standalone CSS stylesheet using the Relaxed config. Sanitize::CSS.stylesheet(css, Sanitize::Config::RELAXED) # Clean up some CSS properties using the Relaxed config. Sanitize::CSS.properties(css, Sanitize::Config::RELAXED) ``` ## Usage Sanitize can sanitize the following types of input: * HTML fragments * HTML documents * CSS stylesheets inside HTML `<style>` elements * CSS properties inside HTML `style` attributes * Standalone CSS stylesheets * Standalone CSS properties > [!WARNING] > > Sanitize cannot fully sanitize the contents of `<math>` or `<svg>` elements. MathML and SVG elements are [foreign elements](https://html.sp阅读完整原文
项目深度分析 AI 生成
跨语言富文本安全清洗 API (SaaS)
| 产品构想 | 将基于 Nokogiri/Crass 的高兼容性 HTML/CSS 清洗引擎封装为高性能无状态 HTTP/gRPC API,服务非 Ruby 生态(如前端直连、Python/Go微服务)。 |
| 核心功能 | HTML/CSS 白名单清洗、防 XSS 规则托管、批量文本过滤、在线测试沙盒。 |
| 目标用户 | 无独立安全团队的中小技术团队、跨语言全栈开发者。 |
| 难度/周期 | 低 · 2-3周 · 成本:极低(每月基础云服务器与域名费用,< $30) |
| 收费模式 | 免费额度 + 按 API 请求调用量计费的订阅制(如每月 $9/50万次)。 |
| 竞争风险 | 网络延迟可能影响同步写入场景;同类语言通常有本地库(如 Python bleach, JS DOMPurify)直接替代,需突出规则统一与托管价值。 |
| 依据 | AI推测 |
富文本编辑器安全集成插件与托管服务
| 产品构想 | 面向 Notion/Tiptap/Quill 等流行富文本编辑器,提供前后端一体化的内容清洗与预设管理工具,解决 SVG、复杂排版保留与安全防护的平衡问题。 |
| 核心功能 | 预置主流编辑器白名单配置、SVG/MathML 安全清理扩展(解决原库限制)、防注入安全评分报告。 |
| 目标用户 | CMS 开发者、知识库 SaaS 团队、社区产品独立开发者。 |
| 难度/周期 | 中等 · 1-2个月 · 成本:低(基础云服务与前端开发环境) |
| 收费模式 | 按席位/域名授权的商业插件许可或按月订阅。 |
| 竞争风险 | README明确指出 SVG/MathML 存在安全盲区,弥补此缺陷的技术难度和安全责任风险极高。 |
| 依据 | 已验证事实 |
企业安全合规策略与依赖维护赞助 (Tidelift / 咨询)
| 产品构想 | 针对在生产环境中重度依赖该 Gem 的企业,提供紧急漏洞响应、定制白名单安全审查以及合规 SLA 担保支持。 |
| 核心功能 | 白名单规则定制化审计、XSS 绕过检测验证、专属安全补丁快速通道。 |
| 目标用户 | 使用 Rails 的中大型电商、金融科技、企业协同软件公司。 |
| 难度/周期 | 中等 · 持续进行 · 成本:主要是个人安全研究与审计时间成本 |
| 收费模式 | 企业支持订阅合同(如年费 $2000-$5000)或安全咨询按天收费。 |
| 竞争风险 | 项目非个人原创时难以代表官方签署高额 SLA,需要极强的安全专业背书。 |
| 依据 | 数据支持的判断 |
AI 基于仓库公开数据分析生成,含推测成分,不构成收益承诺。
报告会保存到 个人中心
竞品与相似项目 GitHub Search 真实检索
相似项目数据正在完善中,暂不展示(避免误导)
项目优势与风险
| 技术成熟度 | 创建时间待补全,最近推送 ,发布过 39 个 Release |
| 社区活跃 | Star 2,056 / Fork 0 / Issue 0(数据支持,可自行核实) |
| 许可证 | 未检测到(需人工确认) |
| 主要风险 | 上游项目方向可能变化;同赛道竞争者较多(见竞品表);热度与需求不完全等价 |
安装与使用
此项目未提供 Docker 镜像,安装步骤以原仓库 README 为准(涉及依赖安装与环境配置,对新手门槛较高)。