Skip to content

fix(svg): track inline styles for CSP#15933

Merged
ematipico merged 1 commit intomainfrom
fix/csp-head-propagation
Mar 16, 2026
Merged

fix(svg): track inline styles for CSP#15933
ematipico merged 1 commit intomainfrom
fix/csp-head-propagation

Conversation

@ematipico
Copy link
Member

Changes

Closes #15838

We now track the style tags inside the SVG elements, and we pass them to createSvgComponent.

If there are styles, we pass the propagation hint so that we can write styles in the end, and correctly generate and track CSP hashes.

Testing

Added a new test, existing tests should pass

Docs

N/A

@changeset-bot
Copy link

changeset-bot bot commented Mar 16, 2026

🦋 Changeset detected

Latest commit: 3ecf45e

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Mar 16, 2026
const Component = createComponent({
async factory(result: SSRResult, props: Record<string, any>) {
const normalizedProps = normalizeProps(attributes, props);
const svgContent = render`<svg${spreadAttributes(normalizedProps)}>${unescapeHTML(children)}</svg>`;
Copy link
Member

Choose a reason for hiding this comment

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

won't this cause the styles to be twice in the page? Because the style tag will still be inside the SVG?

Copy link
Member Author

Choose a reason for hiding this comment

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

True. I rebased the PR and it should be fixed now

@ematipico ematipico force-pushed the fix/csp-head-propagation branch from 08f8d5d to 3ecf45e Compare March 16, 2026 11:41
@ematipico ematipico requested a review from Princesseuh March 16, 2026 11:41
@codspeed-hq
Copy link

codspeed-hq bot commented Mar 16, 2026

Merging this PR will improve performance by 10.19%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 17 untouched benchmarks

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation Build: hybrid site (static + server) 8.8 s 8 s +10.19%

Comparing fix/csp-head-propagation (3ecf45e) with main (23d5244)

Open in CodSpeed

@ematipico ematipico merged commit 325901e into main Mar 16, 2026
26 checks passed
@ematipico ematipico deleted the fix/csp-head-propagation branch March 16, 2026 13:20
@astrobot-houston astrobot-houston mentioned this pull request Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

imported svg <style> tags not bundled causing csp hash warnings

3 participants