Skip to content

feat(security): add server-side email HTML sanitizer utility#1108

Draft
JohnVillalovos wants to merge 1 commit intodevelopfrom
jlvillal/description_escape
Draft

feat(security): add server-side email HTML sanitizer utility#1108
JohnVillalovos wants to merge 1 commit intodevelopfrom
jlvillal/description_escape

Conversation

@JohnVillalovos
Copy link
Collaborator

Add Symfony HTML sanitization support and introduce a reusable EmailHtmlSanitizer utility for email-safe rich text rendering.

  • add dependency: symfony/html-sanitizer (^7.4)
  • add EmailHtmlSanitizer class under lib/Common/Security
  • decode legacy HTML entities before sanitizing
  • allow basic formatting tags and safe link schemes

If needed in the future could use the symfony/html-sanitizer for other tasks.

Add Symfony HTML sanitization support and introduce a reusable
EmailHtmlSanitizer utility for email-safe rich text rendering.

- add dependency: symfony/html-sanitizer (^7.4)
- add EmailHtmlSanitizer class under lib/Common/Security
- decode legacy HTML entities before sanitizing
- allow basic formatting tags and safe link schemes

If needed in the future could use the symfony/html-sanitizer for other
tasks.
Copilot AI review requested due to automatic review settings March 6, 2026 22:44
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a server-side HTML sanitization utility intended for rendering “email-safe” rich text using Symfony’s html-sanitizer, with PHPUnit coverage.

Changes:

  • Added symfony/html-sanitizer (and transitive deps) to Composer requirements/lockfile.
  • Introduced EmailHtmlSanitizer utility with an allowlist of basic formatting elements and safe link schemes.
  • Added unit tests covering allowed formatting, dangerous content removal, and legacy entity-decoding behavior.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
lib/Common/Security/EmailHtmlSanitizer.php New sanitizer utility built on Symfony HtmlSanitizer with an allowlist config and legacy entity decode step.
tests/Common/Security/EmailHtmlSanitizerTest.php New tests validating allowed tags, stripping dangerous content, and decoding encoded HTML before sanitization.
composer.json Adds symfony/html-sanitizer to runtime dependencies.
composer.lock Locks Symfony HtmlSanitizer and new transitive dependencies.

You can also share your feedback on Copilot code review. Take the survey.

@JohnVillalovos JohnVillalovos marked this pull request as draft March 6, 2026 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants