Repository navigation
fix(shared): escape attribute values in buildLucideSvg - #4940
Merged
karsa-mistmere merged 4 commits intoOct 2, 2026
Merged
karsa-mistmere merged 4 commits into
karsa-mistmere merged 4 commits into
Conversation
Attribute values were interpolated into the SVG string as-is, so a value containing a double quote, ampersand or angle bracket (for example in a custom attribute or class name) produced malformed markup.
karsa-mistmere
requested changes
Oct 2, 2026
Member
There was a problem hiding this comment.
Hey @Saadanjum0,
Nice catch, thanks for looking into this and fixing it, I have one proposed change, otherwise this is good to go.
Comment on lines
+4
to
+5
| const escapeAttribute = (value: string) => | ||
| value.replaceAll('&', '&').replaceAll('"', '"').replaceAll('<', '<'); |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
lucide-react-native's tsconfig doesn't include the ES2021 lib that replaceAll requires, failing typecheck. A global regex replace is functionally identical here and works under any target.
Comment on lines
+4
to
+5
| const escapeAttribute = (value: string) => | ||
| value.replace(/&/g, '&').replace(/"/g, '"').replace(/</g, '<'); |
Member
There was a problem hiding this comment.
Updated suggestion:
Suggested change
| const escapeAttribute = (value: string) => | |
| value.replace(/&/g, '&').replace(/"/g, '"').replace(/</g, '<'); | |
| const entities = { | |
| '&': '&', | |
| '<': '<', | |
| '>': '>', | |
| '"': '"', | |
| "'": ''', | |
| } as const; | |
| const escapeAttribute = (value: string) => | |
| value.replace(/[&<>"']/g, char => entities[char as keyof typeof entities]); |
Also escape > and ' per review feedback, not just & " <.
Contributor
Author
|
Updated — now escaping the full set via an entities map, including |
karsa-mistmere
approved these changes
Oct 2, 2026
brandhaug
added a commit
to brandhaug/b2b-saas-starter
that referenced
this pull request
Oct 5, 2026
## pnpm-workspace.yaml (default) ## Dependency Updates | Package | From | To | Type | | --- | --- | --- | --- | | `lucide-react` | 1.49.0 | 1.50.0 | minor | ## Release Notes <details> <summary><b>lucide-react</b> (1.49.0 → 1.50.0)</summary> ## What's Changed * fix(shared): escape attribute values in buildLucideSvg by @<!---->Saadanjum0 in lucide-icons/lucide#4940 * fix(github/actions): use canonical metadata instructions for PR suggestions by @<!---->karsa-mistmere in lucide-icons/lucide#4910 * fix(icons): replaced `nut` & `nut-off` with compliant designs by @<!---->karsa-mistmere in lucide-icons/lucide#4840 * chore(deps-dev): bump @<!---->angular/router from 22.1.7 to 22.2.0 by @<!---->dependabot[bot] in lucide-icons/lucide#4945 * chore(deps): bump next from 16.3.4 to 16.3.6 by @<!---->dependabot[bot] in lucide-icons/lucide#4946 * chore(deps-dev): bump the svelte-deps group with 2 updates by @<!---->dependabot[bot] in lucide-icons/lucide#4918 * test(integrations): add Vue integration fixtures for Vite, Nuxt and Vike by @<!---->ericfennis in lucide-icons/lucide#4882 * feat(svelte): export context subpath by @<!---->vugarbbakhishov-hub in lucide-icons/lucide#4927 * fix(lucide-preact): add Preact v11 compatibility by @<!---->JoviDeCroock in lucide-icons/lucide#4924 * feat(icons): added `layout-grid-circles` icon by @<!---->karsa-mistmere in lucide-icons/lucide#4567 ## New Contributors * @<!---->Saadanjum0 made their first contribution in lucide-icons/lucide#4940 * @<!---->JoviDeCroock made their first contribution in lucide-icons/lucide#4924 **Full Changelog**: lucide-icons/lucide@1.49.0...1.50.0 </details> --- *This PR was auto-generated by [catalog-update-action](https://github.com/brandhaug/catalog-update-action).* Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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.
Problem
buildLucideSvg(andbuildLucideDataUri, which wraps it) interpolates attribute values into the SVG string without escaping. A value such asa "quoted" & bpassed throughattributesorclassNameyields malformed SVG and lets the value break out of the attribute.Cause
buildDomNodeinpackages/shared/src/build/buildLucideSvg.tsbuildsname="${String(value)}"directly.Fix
Escape
&,"and<in attribute values before interpolation.Testing
Added
packages/shared/tests/buildLucideSvg.spec.ts; it fails without the change and passes with it. Fullpackages/sharedvitest suite passes (52 tests).