refactor(util/sanitizer): add shared escapeHtml and SVGAllowlist#597
Merged
Conversation
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).
Coverage Report for CI Build 28759013071Coverage increased (+0.001%) to 94.603%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor — shared sanitizer primitives
Foundational for the security PRs (#593 Autocomplete, #594 Chip, #596 Calendar). Adds two reusable primitives to
util/sanitizer.js, next tosanitizeHtml/DefaultAllowlist, so components stop defining their own copies:escapeHtml(text)— HTML-escape a string (safe for attribute values and text content).SVGAllowlist—DefaultAllowlistextended with SVG elements, moved out ofrating.js(which now imports it). The moved list is a superset (adds a couple of presentational attrs onsvg/line) so it covers both rating and chip icons.No behaviour change;
rating.jskeeps identical sanitization. The dependent security PRs are stacked on this branch and import these instead of re-declaring them.