awesome-repositories.com
Blog
MCP
awesome-repositories.com

Discover the best open-source repositories with AI-powered search.

ExploreCurated searchesOpen-source alternativesSelf-hosted softwareBlogSitemap
ProjectMCP serverAboutHow we rankPress
LegalPrivacyTerms
© 2026 Bringes Technology SRL·VAT RO45896025·hello@awesome-repositories.com
rgrove avatar

rgrove/sanitize

0
View on GitHub↗

Sanitize

Sanitize is a Ruby library designed to clean untrusted HTML and CSS input by enforcing strict security policies. It functions as a web input validator and security filtering tool, processing HTML fragments or full documents to remove unauthorized elements, attributes, and dangerous code patterns that could lead to cross-site scripting or injection attacks.

The library distinguishes itself through a tree-based traversal mechanism that evaluates document structures against customizable allowlists. Beyond standard filtering, it provides granular control over content by allowing developers to inject custom logic for node transformation and URL validation. This enables the application of tailored security policies that can accommodate specific formatting requirements while maintaining a secure output.

The project covers a comprehensive range of sanitization capabilities, including the recursive parsing of style declarations to prevent CSS injection and the reconstruction of sanitized content through document fragment serialization. Developers can configure parsing behavior and define custom rules to balance security needs with the desired level of markup support.

AI search

Explore more awesome repositories

Describe what you need in plain English — the AI ranks thousands of curated open-source projects by relevance.

Start searching with AI

Features

  • HTML Sanitization - Prevents cross-site scripting attacks by stripping malicious elements and attributes from user-provided HTML content before rendering.
  • HTML Allowlists - Enforces security by explicitly permitting only known safe HTML elements and attributes while discarding all other unrecognized input.
  • CSS Injection Preventers - Cleans style attributes and stylesheets to ensure that embedded CSS properties do not contain dangerous or unauthorized code.
  • HTML Element Transformers - Applies specialized logic to inspect or modify specific HTML elements during the sanitization process for complex content requirements.
  • Sanitization Callbacks - Provides hooks for developers to inject custom logic to modify or inspect specific nodes during the sanitization traversal.
  • HTML Fragment Serializers - Reconstructs sanitized content by converting the modified tree structure back into a clean string format for safe output.
  • HTML Node Transformers - Executes custom logic on specific HTML nodes during sanitization to perform complex filtering or modifications beyond standard allowlist checks.
  • Embedded URL Validators - Checks and filters URLs found within HTML attributes or CSS imports to ensure they point to trusted and safe locations.
  • DOM Tree Traversers - Processes HTML by walking a hierarchical document object model to evaluate each element against a defined security policy.
  • CSS Sanitizers - Parses and cleans CSS properties and at-rules within style attributes or stylesheets to prevent malicious injection attacks.
  • Customizable Sanitization Rules - Allows developers to create tailored security policies by merging or overriding default allowlists to permit specific elements and attributes.
  • Document Security Sanitizers - Processes complete HTML documents including doctype definitions to ensure the entire structure adheres to established security policies.
  • HTML Input Validators - Processes untrusted HTML fragments and full documents to ensure they conform to safe, predefined structural standards.
  • HTML Security Policy Enforcers - Enforces standard sets of HTML and CSS restrictions ranging from minimal text-only output to permissive formatting and media support.
  • Resource URL Validations - Enforces security policies on embedded resource URLs within HTML and CSS to prevent unauthorized external loading or malicious injection.
  • Web Content Security Filters - Enforces security policies on web content by stripping unauthorized elements, attributes, and dangerous CSS properties.
  • CSS Style Parsers - Deconstructs style declarations into individual properties and rules to validate them against strict safety constraints before reassembly.
2,055 stars·145 forks·Ruby·MIT·21 views

Star history

Star history chart for rgrove/sanitizeStar history chart for rgrove/sanitize

How this analysis was created: This summary and feature list are AI-generated from collected project material and can contain mistakes. Stars, license and language are imported from GitHub. Inclusion does not mean that we have tested or audited this project. Check the source documentation for any feature you depend on. Learn more on our About page.

Frequently asked questions

What does rgrove/sanitize do?

Sanitize is a Ruby library designed to clean untrusted HTML and CSS input by enforcing strict security policies. It functions as a web input validator and security filtering tool, processing HTML fragments or full documents to remove unauthorized elements, attributes, and dangerous code patterns that could lead to cross-site scripting or injection attacks.

What are the main features of rgrove/sanitize?

The main features of rgrove/sanitize are: HTML Sanitization, HTML Allowlists, CSS Injection Preventers, HTML Element Transformers, Sanitization Callbacks, HTML Fragment Serializers, HTML Node Transformers, Embedded URL Validators.

Which projects share features with rgrove/sanitize?

Projects with overlapping indexed features include: microcosm-cc/bluemonday — bluemonday is a Go library for scrubbing user-generated HTML content to prevent cross-site scripting and other… leizongmin/js-xss — js-xss is an HTML XSS sanitizer and whitelist-based HTML filter designed to remove malicious code from untrusted HTML.… apostrophecms/sanitize-html — This is an HTML sanitization library designed to remove dangerous tags and attributes from user-submitted HTML to… symfony/templating — This library provides a framework for building custom template systems and rendering dynamic content within web… tencent/cherry-markdown — Cherry Markdown is a web-based Markdown editor and parsing engine that converts markup text into sanitized HTML with a… jhy/jsoup — Jsoup is a Java library designed for parsing, extracting, and manipulating HTML and XML content. It provides a…

Projects sharing features with Sanitize

These projects share indexed features with Sanitize. Shared tags can include platform or build tooling; verify the primary use case before treating a result as a replacement.
  • microcosm-cc/bluemondaymicrocosm-cc avatar

    microcosm-cc/bluemonday

    3,688View on GitHub↗

    bluemonday is a Go library for scrubbing user-generated HTML content to prevent cross-site scripting and other injection attacks. It functions as an HTML policy engine and sanitizer that removes dangerous scripts and malicious tags by applying configurable element and attribute allowlists. The project distinguishes itself through a rule-based system that utilizes regular expressions and name-based lists to define permitted tags, attributes, and CSS styles. It includes a URL security validator that enforces safe protocols and automatically injects security attributes such as nofollow and noope

    Goallowlistgogolang
    View on GitHub↗3,688
  • leizongmin/js-xssleizongmin avatar

    leizongmin/js-xss

    5,319View on GitHub↗

    js-xss is an HTML XSS sanitizer and whitelist-based HTML filter designed to remove malicious code from untrusted HTML. It serves as a tool for cross-site scripting prevention and user-generated content management by cleaning HTML strings to ensure safe browser rendering. The library includes a CSS style validator to scrub inline styles against a whitelist and an HTML content purifier capable of stripping all tags to extract raw text. It allows for custom HTML filtering through the definition of specific rules and handler functions to control permitted elements and attributes. The tool covers

    HTML
    View on GitHub↗5,319
  • apostrophecms/sanitize-htmlapostrophecms avatar

    apostrophecms/sanitize-html

    4,129View on GitHub↗

    This is an HTML sanitization library designed to remove dangerous tags and attributes from user-submitted HTML to prevent cross-site scripting attacks. It functions as a content filter that whitelists specific elements and attributes while escaping or discarding unauthorized markup. The project includes an HTML transformation engine that allows for the modification or replacement of tags and attributes using custom logic. It also features a CSS style validator to clean inline properties against permitted patterns and a system for resource URL validation to restrict hostnames and schemes. The

    JavaScript
    View on GitHub↗4,129
  • symfony/templatingsymfony avatar

    symfony/templating

    1,021View on GitHub↗

    This library provides a framework for building custom template systems and rendering dynamic content within web applications. It offers a set of standardized interfaces and tools designed to handle the parsing of template files, the transformation of data into structured output, and the management of template loading from various storage locations. The component distinguishes itself through a modular architecture that supports incremental output streaming, which processes content in chunks to reduce memory usage and improve response times. It also includes integrated security features that au

    PHPcomponentphpsymfony
    View on GitHub↗1,021
Compare all 29 related projects→

Curated searches featuring Sanitize

Hand-picked collections where Sanitize appears.
  • Injection prevention guide