Skip to content

refactor(util/sanitizer): add shared escapeHtml and SVGAllowlist#597

Merged
mrholek merged 1 commit into
mainfrom
refactor/shared-sanitizer-utils
Jul 5, 2026
Merged

refactor(util/sanitizer): add shared escapeHtml and SVGAllowlist#597
mrholek merged 1 commit into
mainfrom
refactor/shared-sanitizer-utils

Conversation

@mrholek

@mrholek mrholek commented Jul 5, 2026

Copy link
Copy Markdown
Member

Refactor — shared sanitizer primitives

Foundational for the security PRs (#593 Autocomplete, #594 Chip, #596 Calendar). Adds two reusable primitives to util/sanitizer.js, next to sanitizeHtml / DefaultAllowlist, so components stop defining their own copies:

  • escapeHtml(text) — HTML-escape a string (safe for attribute values and text content).
  • SVGAllowlistDefaultAllowlist extended with SVG elements, moved out of rating.js (which now imports it). The moved list is a superset (adds a couple of presentational attrs on svg/line) so it covers both rating and chip icons.

No behaviour change; rating.js keeps identical sanitization. The dependent security PRs are stacked on this branch and import these instead of re-declaring them.

Introduce two reusable primitives next to sanitizeHtml/DefaultAllowlist so
components stop defining their own copies:
- escapeHtml(text) — HTML-escape a string (attributes and text content).
- SVGAllowlist — DefaultAllowlist extended with SVG elements (moved out of
  rating.js, which now imports it).

Foundational for the security fixes that consume these (Autocomplete label
escaping, Chip icon sanitize, Calendar aria/label escaping).
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 28759013071

Coverage increased (+0.001%) to 94.603%

Details

  • Coverage increased (+0.001%) from the base build.
  • Patch coverage: 3 of 3 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 7438
Covered Lines: 7161
Line Coverage: 96.28%
Relevant Branches: 3068
Covered Branches: 2778
Branch Coverage: 90.55%
Branches in Coverage %: Yes
Coverage Strength: 747.78 hits per line

💛 - Coveralls

@mrholek
mrholek merged commit 91de7b9 into main Jul 5, 2026
7 checks passed
@mrholek
mrholek deleted the refactor/shared-sanitizer-utils branch July 6, 2026 00:05
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