Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[HtmlSanitizer] Honor universal attribute sanitizers, apply maxInputLength to text contexts, document forceAttribute and allowAttribute caveats#64342

Merged
nicolas-grekas merged 1 commit into
symfony:6.4symfony/symfony:6.4from
nicolas-grekas:hardening-htmlsanitizer-6.4nicolas-grekas/symfony:hardening-htmlsanitizer-6.4Copy head branch name to clipboard
May 23, 2026
Merged

Conversation

@nicolas-grekas
Copy link
Copy Markdown
Member

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues -
License MIT

Hardening, not a security fix. Bundles four small improvements surfaced during a recent audit:

  • DomVisitor::setAttributes() now honors attribute sanitizers registered with the documented null, null wildcard pattern from AttributeSanitizerInterface: the ['*']['*'] slot is added to the array_merge so universal sanitizers actually run.
  • HtmlSanitizer::sanitizeWithContext() applies maxInputLength before the CONTEXT_TEXT early-return path, so text-context calls (sanitizeFor('textarea', …), sanitizeFor('title', …)) cannot exceed the configured limit.
  • HtmlSanitizerConfig::forceAttribute() docblock now documents that the provided value is written verbatim and is not routed through any attribute sanitizer (including UrlAttributeSanitizer). Callers are responsible for ensuring the value is safe.
  • HtmlSanitizerConfig::allowAttribute() docblock now documents its subtractive nature: it restricts the attribute to the listed elements and removes it from any other allowed element that previously had it. Use allowElement($element, [$attribute]) to add an attribute to one element without affecting others.

…ength to text contexts, document forceAttribute and allowAttribute caveats
@carsonbot carsonbot added this to the 6.4 milestone May 23, 2026
@nicolas-grekas nicolas-grekas merged commit 0a62459 into symfony:6.4 May 23, 2026
11 of 13 checks passed
@nicolas-grekas nicolas-grekas deleted the hardening-htmlsanitizer-6.4 branch May 23, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.